Unable to run Ionic app after update to Android Studio 3.0

后端 未结 9 2491
野趣味
野趣味 2020-12-13 04:32

Here\'s my Ionic Info

cli packages: (/Users/billb/dev/customer-mkt-app/node_modules)

@ionic/cli-utils  : 1.15.2
ionic (I         


        
相关标签:
9条回答
  • 2020-12-13 04:57

    If you get this kind of error in Android Studio 3.0.1:

    Unable to resolve dependency for :@debug/compileClasspath’: Could not resolve project :CordovaLib.
    

    Go to build.gradle file -> find dependencies and change it like this

    dependencies {
        compile fileTree(dir: 'libs', include: '*.jar')
        // SUB-PROJECT DEPENDENCIES START
        //debugCompile(project(path: "CordovaLib", configuration: "debug"))
        //releaseCompile(project(path: "CordovaLib", configuration: "release"))
        compile project(':CordovaLib')
        // SUB-PROJECT DEPENDENCIES END
    }
    
    0 讨论(0)
  • 2020-12-13 04:57

    Ok, i found a solution.

    I was using cordova-android: 6.3.0. I updated the version to 7.1.0 and then changed this line in the config.xml

    before was:

    <preference name="android-minSdkVersion" value="16" />
    

    Now i'm using:

    <preference name="android-minSdkVersion" value="19" />
    

    This way, ionic cordova run android is working again without having to change those lines in build.gradle!

    0 讨论(0)
  • 2020-12-13 04:57

    Configuration 'compile' is obsolete and has been replaced with 'implementation'. It will be removed at the end of 2018.

    Simply replace 'compile' with 'implementation'

    dependencies {
        // SUB-PROJECT DEPENDENCIES START
        //debugCompile(project(path: "CordovaLib", configuration: "debug"))
        //releaseCompile(project(path: "CordovaLib", configuration: "release"))
        implementation project(':CordovaLib')
        // SUB-PROJECT DEPENDENCIES END
    }
    
    0 讨论(0)
  • 2020-12-13 05:00

    When you are facing this type of problem, you just de-grade the gradle version to 2.2.3 and re-sync the project it will work.

    0 讨论(0)
  • 2020-12-13 05:01

    I commented the lines below in the build.gradle file:

    //debugCompile project(path: 'CordovaLib', configuration: 'debug') 
    
    //releaseCompile project(path: 'CordovaLib', configuration: 'release')
    

    and added:

    compile project(':CordovaLib')
    

    This worked for me.

    0 讨论(0)
  • 2020-12-13 05:03

    So, I just spent two days battling this and came-up with a semi-manual solution.

    Because Gradle decided to uproot it's dependency format without any grace period for migration, we're forced to do things like this.

    (Instructions under Linux. For Windows you'd need some 7zip or something similar for the last step)

    From your user home directory go to .cordova/lib/npm_cache/cordova-android.
    In there, there should be one or more folders with version numbers.
    Usually only the latest version is run.
    Open it.
    Delete the package directory, but not the package.tgz file.
    Unpack the package.tgz file, then delete it, or move it to a backup location. (there are some extra files generated that we don't want to re-package later)
    Edit the file package/bin/templates/cordova/lib/plugin-build.gradle and inside dependencies remove these lines

    debugCompile project(path: ":CordovaLib", configuration: "debug")
    releaseCompile project(path: ":CordovaLib", configuration: "release")
    

    Replace them with

    implementation project(path: ":CordovaLib")
    

    Archive the package directory. In Linux the short command is tar czf package.tgz package. On Windows, you'd have to create a .tar.gz archive with 7zip and rename it to .tgz.

    After that, in running a cordova prepare in a clean repository that worked with the old versions will work again, unless some of the plugins explicitly use the old declaration format and need to be updated (example)

    0 讨论(0)
提交回复
热议问题