我正在寻找一种方法来分离我正在创建的应用程序的代码。这只是实验者,我不确定这是不是好事
我的项目结构是这样的
| - 应用程序
|
|--登录
在我的登录 android 库中,我的登录屏幕只有两个输入字段,没什么特别的。
那么,我如何在我的应用程序项目中使用它?
我是否需要发布它才能将其用作网址?或者我可以在内部使用它?
设置.gradle
include ':app', ':login'
登录库 build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'
}
和应用程序 build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.app.mandala"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'
implementation project(':login')
}
而且我似乎无法在我的应用程序内部布局中包含登录库/模块。
在您的库 build.gradle 中替换以下行:
implementation fileTree(dir: 'libs', include: ['*.jar'])
和
api fileTree(dir: 'libs', include: ['*.jar'])
在您的应用 build.gradle 中,删除以下行:
implementation fileTree(include: ['*.jar'], dir: 'libs')
例如,在您的布局 xml 中,您可能必须包含完整的包名称 <com.domain.project.CustomLoginView>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句