フレーバーを設定しようとしているので、同じコードを共有する同じプロジェクトで別のアプリケーションを作成できます...しかし、私は私は、フォルダWでcom.sharedid.appと呼ばれるプロジェクトを作成したAndroidスタジオでのフレーバーの使用 - 間違ったAndroidManifestの選択/非統合
...完全に正しいことをしています:\ androidのスタジオ・プロジェクトを\ sharedidこのため
は私が
を持っている\ 1) W:\ android-studio-projects \ sharedid \ app \ src \ mainのlookinでAndroidManifest.xmlを作成しましたこのようなグラム:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sharedid.app"
android:versionCode="1"
android:versionName="1.0"
>
<activity android:name="com.shared.app.SharedMain" android:label="@string/MicMainName" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</manifest>
2)W で:\ androidのスタジオ・プロジェクト\ sharedid \アプリ\ SRC \メイン\のJava ...私はすべての.javaファイルを持っている
3) Wで:\ androidのスタジオ・プロジェクト\ sharedid \アプリ\ SRC \メイン\ RES私はすべて私が持っている私の味についておよび/またはダミーリソース
を共有しています
1)私はWでのAndroidManifest.xmlを作成しました:アンドロイド・スタジオ・プロジェクト\ \ sharedid \アプリ\ SRC \ myflavour(このファイルはすべてのものを定義するものである - それはそれぞれの味のためunqiueです)
2) でW:\ androidのスタジオ・プロジェクト\ sharedid \アプリ\ SRC \ myflavour \ RES私は描画可能-hdpi conttainingは Wでグラフィック
3)単一のフォルダをvarioisている:\ androidのスタジオ・プロジェクトに\ sharedid \ app \ src \ myflavour \ assetsのすべての種類のデータ、設定、グラフィックファイルがあります。特定のアプリ。 *のWで )
4を(実行時にコードで読み取り):
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myflavour.app"
android:versionCode="2"
android:versionName="2.0"
>
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="17"
/>
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/app_logo__forlarge"
android:label="@string/MicAppName"
android:theme="@style/MicTheme_myflavour"
android:name="com.shared.app.MicApp"
>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.myflavour.app.fileprovider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_filepaths" />
</provider>
<activity android:name="com.shared.app.SharedMain" android:label="@string/MicMainName" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity>...more...</activity>
</application>
</manifest>
:アンドロイド・スタジオ・プロジェクト\ \ sharedid \アプリ\ SRC \ myfavlour *私は、次ののAndroidManifest.xmlファイルを持っています私の問題は、この
です
apply plugin: 'com.android.application'
android {
signingConfigs {
}
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
applicationId "com.sharedid.app"
minSdkVersion 9
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
repositories {
maven { url "https://jitpack.io" }
}
productFlavors {
myflavour {
applicationId "com.myflavour.app"
}
}
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
}
myflavour {
manifest.srcFile 'src/myflavour/AndroidManifest.xml'
}
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:21.1.2'
compile 'com.github.PhilJay:MPAndroidChart:v2.0.8'
}
:次のようになります(アプリモジュール)は、 "Gradleのを構築する" - ここに
はどのように "のGradleスクリプト" です
"ビルドバリアント"で "module = app"と "build-variant = com.myflavour.appDebug"を選択し、 "実行>デバッグ..."をクリックします。"エラー:デフォルトのアクティビティ私は右のそれabnoutていたら...私は味のためのファイルのデフォルトconventenionを使用するので、私はsourcesetsパスを定義する必要はありません味の私の研究から「
が見つかりません - そして、なぜそれが見えません。フレーバーのAndroidmanifestファイルが選択されていますか?参照用
リンクは、私が上で私の理解を基礎:この問題の根本を見つけるために、私の試みで
- https://developer.android.com/tools/building/manifest-merge.html
- Gradle flavors for android with custom source sets - what should the gradle files look like?
追加のトラブルシューティング
、Iマニフェスト合併がうまくいかないと思われ始めた。この疑惑の理由は、私が何の行動もしなかったことを無視して、コンパイルされたアプリをモバイル上にプッシュしようとすると、バージョン番号がモバイル明確なマニフェストにインストールされているバージョン番号よりも小さいという警告が表示されるファイルが使用されていました。
だから私は、エラーになりのsrc /メイン/ AndroidManifest.xmlを削除しようとしています:
A problem was found with the configuration of task ':app:checkmyflavourDebugManifest'. File W:\android-studio-projects\sharedid\src\main\AndroidManifest.xml' specified for property 'manifest' does not exist
これは、Android Studioは完全に私が実際にそれを使用するように指定していますことを無視していると信じて私をリードしますもう一つのマニフェストファイル...そして同じ時間に、私は正しいバリエーションビルドを構築するように見えるでしょう。
私はこの上の任意のコメント/分析をapreciateだろう - ちょうど(このスクリーンショットでは、私は共有/メイン削除experiementedてきた私の現在の設定の原因
スクリーンショット
の私の考えを確認しても、 androidmanifestファイルが、それ以外の場合は、完全な)
最新の更新
私はflavoを締結rsが動作していない/私のgradleの設定が間違っている必要があります。たとえば、建物のバリエーションを選択myflavourDebug Androidスタジオはgradleで定義されたマニフェストファイルを使用しません。これだけで問題がどこに依存しているかを判断するのに十分なはずです。
私のgradleファイルは何とか間違っているかもしれませんが、わかりませんが、私は正しいことに大いに注意しました。賞金が稼動している間に誰かが賞品を掲示したら、私は急いでそれを割り当てようとします。
AndroidManifestはアクティビティを含むクラスを記述する必要があると思います。 – jrsall92
それぞれの味は独自のAndroidManifestを持っています。マニフェストファイルをマージする方法に関するGoogle独自のドキュメントへのリンクは次のとおりです。https://developer.android.com/tools/building/manifest-merge.html - 多分私はそれを誤解してしまいました – Tom
マニフェストファイルにはアクティビティクラスが必要です私はマニフェストファイルでそれを見ていない。アクティビティクラス名は何ですか?アプリケーションタグのマニフェストファイルに追加する必要があります。 –