[英]Include apk module as dependency in android studio
I have two modules in my project: 我的项目中有两个模块:
Both modules have java and res. 两个模块都有java和res。
app_list
has some activities that I want to launch in app
. app_list
有一些我想在app
启动的活动。
In Eclipse, I had app_list as dependency library and I was able to launch activity of app_list
. 在Eclipse中,我将app_list作为依赖库,并且能够启动
app_list
活动。 In Android Studio, when I added app_list
as dependency, it says: 在Android Studio中,当我添加
app_list
作为依赖项时,它说:
"Error:A problem occurred configuring project ':app'.
> Dependency NewMathBuzz:app_list:unspecified on project app resolves to an APK archive which is not supported as a compilation dependency. File: <home>/NewMathBuzz/app_list/build/outputs/apk/app_list-release-unsigned.apk
"
app > build.gradle is as below: 应用> build.gradle如下:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.mass.mathbuzz"
minSdkVersion 7
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile project(':app_list')
compile fileTree(dir: 'libs', include: ['*.jar'])
}
app_list > build.gradle is as below: app_list> build.gradle如下:
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 7
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.mcxiaoke.volley:library:1.0.18'
compile 'com.android.support:appcompat-v7:22.0.0'
}
Could someone help me with this? 有人可以帮我吗?
Everything was fine, 一切都很好
basically when I changed app_list.gradle
as 基本上当我将
app_list.gradle
更改为
apply plugin: 'com.android.application'
to apply plugin: 'com.android.library'
and deleted applicationId
from app_list.gradle
it compiled and generated apk but I was getting runtime error that was because both app and app_list both had same resource main_activity so R.java didn't have main_activity
res of app_list
so it was giving illegal_parameter error . apply plugin: 'com.android.application'
以apply plugin: 'com.android.library'
并从app_list.gradle
删除了applicationId
编译并生成了apk,但我遇到了运行时错误,原因是因为app和app_list都具有相同的资源main_activity,因此R.java没有app_list
main_activity
res,因此它给出了invalid_parameter错误。 When I changed name of main_activity
to some unique name it solved the issue 当我将
main_activity
名称更改为一些唯一的名称时,它解决了该问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.