Flavored-Library icon indicating copy to clipboard operation
Flavored-Library copied to clipboard

Use in studio 3.0.1 and can not find 'xyz.sahildave.mylibrary'

Open qlang122 opened this issue 6 years ago • 1 comments

in android studio 3.0.1 , gradle-4.1-all. the project build failed,can`t find the class. output details:

C:\Users\Administrator\Desktop\Flavored-Library-master\app\src\main\java\xyz\sahildave\flavoredlibrary\MainActivity.java:7: 错误: 程序包xyz.sahildave.mylibrary不存在 import xyz.sahildave.mylibrary.LibraryActivity; ^ C:\Users\Administrator\Desktop\Flavored-Library-master\app\src\main\java\xyz\sahildave\flavoredlibrary\MainActivity.java:15: 错误: 找不到符号 Intent intent = new Intent(this, LibraryActivity.class); ^ 符号: 类 LibraryActivity 位置: 类 MainActivity 2 个错误

FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:compileApp1521DebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.


but gradle config sysc is no error.

qlang122 avatar Feb 25 '19 08:02 qlang122

library build.gradle

apply plugin: 'com.android.library'

android { buildToolsVersion "26.0.2"

publishNonDefault true

defaultConfig {
    versionCode 1
    versionName "1.0"
    flavorDimensions "default"
}
productFlavors {
    sdk1521 {
        minSdkVersion 15
        targetSdkVersion 26
        compileSdkVersion 26
    }
    sdk1524 {
        minSdkVersion 15
        targetSdkVersion 26
        compileSdkVersion 26
    }
}

} configurations { sdk1521Debug sdk1524Debug } dependencies { // compile 'com.android.support:appcompat-v7:24.2.1' sdk1524Compile 'com.android.support:appcompat-v7:26.1.0' sdk1521Compile 'com.android.support:appcompat-v7:26.1.0' }

app build.gradle

apply plugin: 'com.android.application'

android { buildToolsVersion "26.0.2"

defaultConfig {
    applicationId "xyz.sahildave.flavoredlibrary"
    versionCode 1
    versionName "1.0"

    flavorDimensions "default"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
productFlavors {
    app1521 {
        minSdkVersion 15
        targetSdkVersion 26
        compileSdkVersion 26
        applicationId "xyz.sahildave.flavoredlibrary.app1521"
    }
    app1524 {
        minSdkVersion 15
        targetSdkVersion 26
        compileSdkVersion 26
        applicationId "xyz.sahildave.flavoredlibrary.app1524"
    }
}

}

configurations { app1521DebugCompile app1524DebugCompile }

dependencies { // compile 'com.android.support:appcompat-v7:24.1.0' app1521DebugCompile project(path: ':mylibrary', configuration: 'sdk1521Debug') app1524DebugCompile project(path: ':mylibrary', configuration: 'sdk1524Debug') app1521DebugCompile 'com.android.support:appcompat-v7:26.1.0' app1524DebugCompile 'com.android.support:appcompat-v7:26.1.0' }

qlang122 avatar Feb 25 '19 08:02 qlang122