前提・実現したいこと
Andrriud Studioにてメインプロジェクト、モジュールプロジェクトから成る、
マルチプロジェクト環境を構築したいと思っています。
サンプルのため、下記フォルダ構成で、
プロジェクトをAndroid Studioから新規作成しました。
それぞれのBuildは問題なく終了します。
AndroidStudioProjects - MyApplication - app - settings.gradle - build.gradle ・ ・ - MyModule - app - settings.gradle - build.gradle ・ ・
発生している問題・エラーメッセージ
1.MyModuleプロジェクトを新規作成
→ No activityで作成し、その後モジュール化
apply plugin: 'com.android.application'
→apply plugin: 'com.android.library'
2.MyApplicationのsetting.gradleにMyModuleプロジェクトへの参照追記
rootProject.name='My Application' include ':app',':module' project(':module').projectDir = file('../../MyModule')
3.MyApplicationのbuild.gradleにMyModuleプロジェクトへの依存追記
dependencies { ・ ・ implementation project(':module') }
4.MyApplicationにてGradle Syncを実行すると下記エラーとなる
- Syncエラーメッセージ
ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve project :module. Show Details Affected Modules: app
- Buildエラーメッセージ
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'. > Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'. > Could not resolve project :MyModule:module. Required by: project :app > Unable to find a matching configuration of project :MyModule:module: - None of the consumable configurations have attributes.
該当のソースコード
setting.gradle(MyApplication)
rootProject.name='My Application' include ':app' include ':MyModule' project(':MyModule').projectDir = new File(settingsDir, '../MyModule/') include ':MyModule:module'
build.gradle(MyApplication)
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 29 buildToolsVersion "29.0.3" defaultConfig { applicationId "com.example.myapplication" minSdkVersion 21 targetSdkVersion 29 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } // To inline the bytecode built with JVM target 1.8 into // bytecode that is being built with JVM target 1.6. (e.g. navArgs) compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = "1.8" } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.core:core-ktx:1.0.2' implementation 'com.google.android.material:material:1.0.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.navigation:navigation-fragment-ktx:2.0.0' implementation 'androidx.navigation:navigation-ui-ktx:2.0.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' implementation project(path: ':MyModule:module') // この行を追加 }
build.gradle(MyModule)
apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 29 buildToolsVersion "29.0.3" defaultConfig { minSdkVersion 21 targetSdkVersion 29 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.core:core-ktx:1.2.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' }
試したこと
- 依存関係の追記
ここを参照して'matchingFallbacks'の追記
→ 効果なし
- 'implementation project(':module')'を依存関係が伝搬しない'api project(':module')'に変更
→ 効果なし
新規にプロジェクトを作成して試してみても同じエラーが発生するため、
自分の方法が根本的にどこか間違っていると思うのですが、いいアイデアが見つかりません。
補足情報(FW/ツールのバージョンなど)
開発マシン:Mac book pro
Android studio:3.6.1
Gradle version:5.6.4
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/03/09 06:17
2020/03/09 06:38
2020/03/10 04:51