[英]How to include java library in existing Android project in Android Studio
我想将zxcvbn包含在我现有的android项目中,但无法执行。 已经尝试
如何将现有的Java项目导入Android Studio?
Android Studio:将项目添加为库
将外部Android和Java项目添加到Android Studio中的Android项目
但没有运气。 根据我的项目要求,我将不使用'compile com.nulab-inc:zxcvbn:1.2.2',因为我需要在项目中使用源代码。
我的build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '24.0.3'
defaultConfig {
applicationId "xx.xxx.xx"
minSdkVersion 14
targetSdkVersion 24
// Enabling multidex support.
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
lintOptions {
abortOnError false
}
productFlavors {
}
}
repositories {
mavenCentral()
maven { url 'http://guardian.github.com/maven/repo-releases' }
}
dependencies {
compile files('libs/xx-3.0.2.jar')
compile files('libs/xx-android-sdk-1.6.3.jar')
compile project(':utilities')
compile project(path: ':common')
compile project(':common')
compile 'com.google.http-client:google-http-client-gson:1.19.0'
compile 'com.google.code.gson:gson:2.4'
compile 'com.google.android.gms:play-services-base:9.0.2'
compile 'com.google.android.gms:play-services-analytics:9.0.2'
compile 'com.google.android.gms:play-services-wearable:9.0.2'
compile 'com.google.android.gms:play-services-auth:9.0.2'
compile 'com.google.apis:google-api-services-drive:v2-rev164-1.20.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.xx.xx:xx:1.2.2'
compile 'com.x.x:x-compiler:1.2.2'
compile 'com.x.x:x-v7:24.0.0'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.google.android.gms:play-services-appindexing:9.0.2'
}
android {
useLibrary 'org.apache.http.legacy'
}
configurations {
all*.exclude group: 'com.google.guava', module: 'guava-jdk5'
}
您应该将其导入为Android项目的新模块,请按照以下步骤将其添加为新模块
1.Go to file -> New - > Import Module
并选择您的zxcvbn库位置路径,然后单击“完成”。 这会将一个新模块添加到您现有的android项目中。
然后,您应该在项目依赖项中添加一个新模块,即您的(zxcvbn库)
2.Click project structure options - > dependency select your zxcvbn library and click ok and synch project
现在您的Java库包含在您的android项目中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.