无法访问我作为库导入的项目中的 class 个文件
Can't access class files from project which I imported as a library
我在我的基础项目中导入了一个项目作为库,但我无法访问我的基础项目中导入的库中存在的 class 文件。如果问题很愚蠢,请原谅我,我是 android 工作室的新手
我做的步骤 -
- 将应用插件:'com.android.application'更改为应用插件:'com.android.library'
- 添加了实施项目(':project_name')
- 将compileSdkVersion、minSdkVersion和targetSdkVersion改成相同的值
- 是否使缓存无效/重新启动
以下是我的 gradle 个文件
build.gradle(:app)(主要项目)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.consensus.deg_project"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:25.12.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-auth:19.4.0'
implementation 'com.google.firebase:firebase-firestore:22.0.0'
implementation 'com.google.android.gms:play-services-auth:18.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.google.firebase:firebase-database:19.2.0'
implementation('com.google.api-client:google-api-client-android:1.23.0') {
exclude group: 'org.apache.httpcomponents'
exclude group:'com.google.guava'
}
implementation('com.google.apis:google-api-services-sheets:v4-rev506-1.23.0') {
exclude group: 'org.apache.httpcomponents'
exclude group:'com.google.guava'
}
implementation 'com.shobhitpuri.custombuttons:google-signin:1.0.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.navigation:navigation-fragment:2.3.1'
implementation 'androidx.navigation:navigation-ui:2.3.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'me.dm7.barcodescanner:zxing:1.9'
implementation 'com.android.volley:volley:1.1.1'
implementation 'pub.devrel:easypermissions:0.3.0'
implementation project(':TF_Lite')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
build.gradle(:TF_Lite)(作为库导入的项目)
apply plugin: 'com.android.library'
android {
compileSdkVersion 29
defaultConfig {
applicationId "org.tensorflow.lite.examples.classification"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
aaptOptions {
noCompress "tflite"
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
lintOptions {
abortOnError false
}
flavorDimensions "tfliteInference"
productFlavors {
// The TFLite inference is built using the TFLite Support library.
support {
dimension "tfliteInference"
}
// The TFLite inference is built using the TFLite Task library.
taskApi {
dimension "tfliteInference"
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
supportImplementation project(":lib_support2")
taskApiImplementation project(":lib_task_api2")
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'com.google.truth:truth:1.0.1'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.1.0'
}
所以我所要做的就是添加这个:-
flavorDimensions "tfliteInference"
productFlavors {
// The TFLite inference is built using the TFLite Support library.
support {
dimension "tfliteInference"
}
// The TFLite inference is built using the TFLite Task library.
taskApi {
dimension "tfliteInference"
}
}
在我的主要项目的构建中 gradle
我在我的基础项目中导入了一个项目作为库,但我无法访问我的基础项目中导入的库中存在的 class 文件。如果问题很愚蠢,请原谅我,我是 android 工作室的新手 我做的步骤 -
- 将应用插件:'com.android.application'更改为应用插件:'com.android.library'
- 添加了实施项目(':project_name')
- 将compileSdkVersion、minSdkVersion和targetSdkVersion改成相同的值
- 是否使缓存无效/重新启动 以下是我的 gradle 个文件
build.gradle(:app)(主要项目)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.consensus.deg_project"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:25.12.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-auth:19.4.0'
implementation 'com.google.firebase:firebase-firestore:22.0.0'
implementation 'com.google.android.gms:play-services-auth:18.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.google.firebase:firebase-database:19.2.0'
implementation('com.google.api-client:google-api-client-android:1.23.0') {
exclude group: 'org.apache.httpcomponents'
exclude group:'com.google.guava'
}
implementation('com.google.apis:google-api-services-sheets:v4-rev506-1.23.0') {
exclude group: 'org.apache.httpcomponents'
exclude group:'com.google.guava'
}
implementation 'com.shobhitpuri.custombuttons:google-signin:1.0.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.navigation:navigation-fragment:2.3.1'
implementation 'androidx.navigation:navigation-ui:2.3.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'me.dm7.barcodescanner:zxing:1.9'
implementation 'com.android.volley:volley:1.1.1'
implementation 'pub.devrel:easypermissions:0.3.0'
implementation project(':TF_Lite')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
build.gradle(:TF_Lite)(作为库导入的项目)
apply plugin: 'com.android.library'
android {
compileSdkVersion 29
defaultConfig {
applicationId "org.tensorflow.lite.examples.classification"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
aaptOptions {
noCompress "tflite"
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
lintOptions {
abortOnError false
}
flavorDimensions "tfliteInference"
productFlavors {
// The TFLite inference is built using the TFLite Support library.
support {
dimension "tfliteInference"
}
// The TFLite inference is built using the TFLite Task library.
taskApi {
dimension "tfliteInference"
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
supportImplementation project(":lib_support2")
taskApiImplementation project(":lib_task_api2")
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'com.google.truth:truth:1.0.1'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.1.0'
}
所以我所要做的就是添加这个:-
flavorDimensions "tfliteInference"
productFlavors {
// The TFLite inference is built using the TFLite Support library.
support {
dimension "tfliteInference"
}
// The TFLite inference is built using the TFLite Task library.
taskApi {
dimension "tfliteInference"
}
}
在我的主要项目的构建中 gradle