Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R2 not found in my library module #1597

Open
Jafar396 opened this issue Mar 26, 2020 · 4 comments
Open

R2 not found in my library module #1597

Jafar396 opened this issue Mar 26, 2020 · 4 comments

Comments

@Jafar396
Copy link

Jafar396 commented Mar 26, 2020

I try to merge two project and when I convert the second project to library module the @BindView(R.id.xxx) in library is tell me (attribute value must be a constant) and when I research I add in my library module:
apply plugin: 'com.android.library'
apply plugin: 'com.jakewharton.butterknife'
and:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
and:
implementation 'com.jakewharton:butterknife:10.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
and I add in my project:
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

my gradle is 5.6.4
but when I replace R to R2 , The R2 is not found
please help me

@JakeWharton
Copy link
Owner

Please provide a sample project that demonstrates the issue.

@Jafar396
Copy link
Author

Jafar396 commented Mar 26, 2020

@JakeWharton

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.61'
repositories {
mavenCentral()
google()
jcenter()

}
dependencies {
    classpath 'com.android.tools.build:gradle:3.6.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

allprojects {
repositories {
google()
jcenter()
maven {
url'https://maven.google.com'
}
maven {url "https://jitpack.io"}
maven {url "http://dl.bintray.com/tbruyelle/tbruyelle" }

}

}

task clean(type: Delete) {
delete rootProject.buildDir
}


and in my module:app

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28

defaultConfig {
    applicationId "com.js.mypharmacist"
    minSdkVersion 26
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

// To inline the bytecode built with JVM target 1.8 into
// bytecode that is being built with JVM target 1.6. (e.g. navArgs)

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
buildToolsVersion = '28.0.3'
kotlinOptions {
    jvmTarget = "1.8"
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(":omniNotess")

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment:2.2.1'
implementation 'androidx.navigation:navigation-ui:2.2.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.2.1'
implementation 'androidx.navigation:navigation-ui-ktx:2.2.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'


// App dependencies

implementation("com.android.support:support-annotations:28.0.0")
implementation("ch.acra:acra:4.6.1")
implementation("com.melnykov:floatingactionbutton:1.2.0")
implementation("io.reactivex.rxjava2:rxjava:2.2.0")
implementation("io.reactivex.rxjava2:rxandroid:2.1.0")
implementation("com.f2prateek.rx.preferences2:rx-preferences:2.0.0")
implementation("com.android.support:support-v4:28.0.0") {}

// Testing-only dependencies
testImplementation("net.wuerl.kotlin:assertj-core-kotlin:0.1.1")
testImplementation("junit:junit:4.12")
testImplementation("org.mockito:mockito-core:2.23.4")

androidTestImplementation("com.squareup.assertj:assertj-android:1.1.1")
// Force usage of support annotations in the test app, since it is internally used by the runner module.
androidTestImplementation("com.android.support:support-annotations:28.0.0")
androidTestImplementation("com.android.support.test:runner:1.0.2") {}
androidTestImplementation("com.android.support.test:rules:1.0.2") {}
androidTestImplementation("com.android.support.test.espresso:espresso-core:3.0.2")
androidTestImplementation("com.bartoszlipinski:cortado:1.2.0")
//for some tests which do not work with espresso on travis
androidTestImplementation("com.jayway.android.robotium:robotium-solo:5.2.1")

}


and in my module library::
apply plugin: 'com.android.library'
apply plugin: 'com.jakewharton.butterknife'

boolean signConfigExists = project.hasProperty("SIGN_PROPS") && new File(project.property("SIGN_PROPS")).exists()
if(signConfigExists) {
Properties props = new Properties()
props.load(new FileInputStream(file(project.property("SIGN_PROPS"))))

android {

    signingConfigs {
        release {
            storeFile file(props['keystore'])
            storePassword props['keystore.password']
            keyAlias props['keystore.alias']
            keyPassword props['keystore.alias.password']
        }
    }
}

}

android {

if (project.hasProperty("SIGN_PROPS")
        && new File(project.property("SIGN_PROPS").toString()).exists()) {
    Properties props = new Properties()
    props.load(new FileInputStream(file(project.property("SIGN_PROPS"))))
    signingConfigs {
        signConfig {
            storeFile file(props['keystore'])
            storePassword props['keystore.password']
            keyAlias props['keystore.alias']
            keyPassword props['keystore.alias.password']
        }
    }
}

compileSdkVersion Integer.parseInt(project.TARGET_SDK)
buildToolsVersion project.BUILD_TOOLS

defaultConfig {

    minSdkVersion project.MIN_SDK
    targetSdkVersion project.TARGET_SDK
    versionName project.VERSION_NAME
    versionCode Integer.parseInt(project.VERSION_CODE)


    vectorDrawables.useSupportLibrary = true
    testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
    multiDexEnabled true

}

testOptions {
    unitTests.returnDefaultValues = true
}

packagingOptions {
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
}

buildTypes {

    debug {

        testCoverageEnabled false

    }
    release {
        minifyEnabled true
        shrinkResources false
        multiDexEnabled false
        testCoverageEnabled false

        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'

        if(signConfigExists) {
            signingConfig signingConfigs.release
        }
    }
}



lintOptions {
    abortOnError false
    disable 'MissingTranslation'
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

}

dependencies {
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-all:1.9.5'
testImplementation 'org.powermock:powermock:1.6.5'
testImplementation 'org.powermock:powermock-module-junit4:1.6.5'
testImplementation 'org.powermock:powermock-api-mockito:1.6.5'

androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation ('androidx.test.espresso:espresso-intents:3.1.0') {
    exclude group: 'com.android.support', module: 'support-annotations'
}

compileOnly "org.projectlombok:lombok:1.18.10"
annotationProcessor 'org.projectlombok:lombok:1.18.10'

implementation 'com.larswerkman:HoloColorPicker:1.4'
implementation 'de.keyboardsurfer.android.widget:crouton:1.8.4@aar'
implementation 'com.google.android.apps.dashclock:dashclock-api:2.0.0'
implementation "ch.acra:acra-http:5.4.0"
implementation "ch.acra:acra-toast:5.4.0"
implementation 'com.github.gabrielemariotti.changeloglib:changelog:2.0.0'
implementation 'com.appeaser.sublimepickerlibrary:sublimepickerlibrary:2.1.2'
implementation 'androidx.preference:preference:1.1.0'
implementation 'com.android.support:multidex:2.0.1'
implementation 'com.google.android.material:material:1.0.0'
implementation 'de.greenrobot:eventbus:2.4.0'
implementation 'com.pushbullet:android-extensions:1.0.4@aar'
implementation 'com.getbase:floatingactionbutton:1.10.1'
implementation 'com.nhaarman.listviewanimations:lib-core:3.1.0@aar'
implementation 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0@aar'
implementation 'com.github.bumptech.glide:glide:4.10.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
implementation('com.github.afollestad.material-dialogs:core:0.9.6.0') {
    transitive = true
    exclude group: "com.android.support"
}
implementation('com.github.afollestad.material-dialogs:commons:0.9.6.0') {
    transitive = true
    exclude group: "com.android.support"
}
implementation 'com.jakewharton:butterknife:10.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
implementation('org.mnode.ical4j:ical4j:3.0.11') {
    exclude group: 'commons.io'
}
debugImplementation ('com.squareup.leakcanary:leakcanary-android:1.6.2') {
    exclude group: "com.android.support"
}
implementation 'org.apache.commons:commons-lang3:3.9'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.2'
testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.2'
implementation 'com.pnikosis:materialish-progress:1.5'
implementation 'com.github.paolorotolo:appintro:1.3.0'
implementation 'io.reactivex:rxandroid:1.0.1'
implementation 'io.reactivex:rxjava:1.0.14'
implementation 'com.artemzin.rxjava:proguard-rules:1.0.14.2'
implementation 'com.tbruyelle.rxpermissions:rxpermissions:0.4.2@aar'
implementation 'org.ocpsoft.prettytime:prettytime:3.2.7.Final'
implementation 'org.bitbucket.cowwoc:diff-match-patch:1.1'
implementation 'com.github.bosphere.android-filelogger:filelogger:1.0.7'


implementation('com.github.federicoiosue:simplegallery:3.0.1') {
    exclude group: 'com.android.support'
}
implementation 'com.github.federicoiosue:Springpad-Importer:1.0.1'
implementation ('com.github.federicoiosue:Omni-Notes-Commons:1.2.0') {
    exclude group: 'org.projectlombok'
}
implementation ('com.github.federicoiosue:checklistview:3.2.1') {
    transitive=false
}
implementation 'com.github.federicoiosue:pixlui:3.0.0'

// Flavors specific dependencies
implementation 'io.nlopez.smartlocation:library:3.2.4'


implementation ('com.github.federicoiosue:analitica:0.0.3:googleAnalyticsRelease@aar'){
    transitive=true
}

implementation 'com.google.android.gms:play-services-analytics:9.0.2'


testImplementation 'junit:junit:4.12'

}

configurations.all {
exclude group: 'commons-logging', module: 'commons-logging'
resolutionStrategy {
force 'com.android.support:support-annotations:28.0.0'
force 'com.android.support:support-v4:28.0.0'
}
}
my android studio 3.6.1 and my gradle 5.6.4 and my build tool version 28.0.3

@Jafar396
Copy link
Author

I need to help my friend
@JakeWharton

@JakeWharton
Copy link
Owner

A bunch of snippets doesn't help me reproduce your problem. I need a self-contained project zip that I can just open, hit run, and see the failure, ideally with as little other code as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants