Eclipse android project to android studio

The old project of the former company was developed with eclipse. Although android studio has been out for a long time, it has been trying to avoid some problems in migration, but recently Google has asked that android projects be compiled with android 8.0. Then it is found that eclipse+ADT no longer supports jdk 1.8 and android 8.0, so there will be problems in operation, similar to unsported 520, there are also a variety of unexplained errors, such as not recognizing 27, then searching some blogs and saying that you can download two plug-ins. Then I try to download the first plug-in in the application market. No problem with downloading the first plug-in, but when the second problem is loaded to 15, it will always make a mistake and cannot be solved, and then think about migrating into android studio as well, so there are pits as the following:

1. The first question is how the android project developed by eclipse can become an android studio project in two ways. I use File->Export->Generate Gradle build files and go on to choose the project you want to export (regardless of the dependent project, it will be exported automatically). The other way is to open android studio without modifying the eclipse project.Select import project(eclipse ADT.), however: Note that there are many problems when importing in this way. If you refer to many external jar packages, you will encounter a lot of messy problems. At first, because I can't solve them, I gave up transferring to android studio, and used eclipse to generate gradle projects, open them directly with android studio, avoiding some problems.

2.Step 2, It's best to use the latest 3.1.4 for android studio: Opening the eclipse android project with android studio will encounter some issues that need to be downloaded again for the gradle version. To solve these problems, open avd managment, download, click sync to sync and then download it automatically. The latest android studio will help you solve many problems that Google's resources are not accessible.This is a lot of proxy settings done internally. Before using eclipse, it was necessary to set up a proxy/mirror web address.

3.Question 3: If you have referenced so file in your project, automatically generating android studio project will result in errors. The following errors are usually caused by not referencing the so file of armeabi under this libs in your android studio build.gradle. You need to add the following code in build.gradle:

4. After the third step, the project will run normally on your mobile phone, but next time you want to publish the release version, you will encounter problems. Before signing packages in eclipse, it is easy to import the keystore file, migrate to android studio, use his signature method, jks, and find many strange errors. debug's signature packages will not report errors:

Could not find org.jetbrains.kotlin:kotlin-reflect:1.2.41.
Searched in the following locations:
  - file:/E:/android/adt-bundle-windows-x86-20130917/sdk/extras/m2repository/org/jetbrains/kotlin/kotlin-reflect/1.2.41/kotlin-reflect-1.2.41.pom
  - file:/E:/android/adt-bundle-windows-x86-20130917/sdk/extras/m2repository/org/jetbrains/kotlin/kotlin-reflect/1.2.41/kotlin-reflect-1.2.41.jar
  - file:/E:/android/adt-bundle-windows-x86-20130917/sdk/extras/google/m2repository/org/jetbrains/kotlin/kotlin-reflect/1.2.41/kotlin-reflect-1.2.41.pom
  - file:/E:/android/adt-bundle-windows-x86-20130917/sdk/extras/google/m2repository/org/jetbrains/kotlin/kotlin-reflect/1.2.41/kotlin-reflect-1.2.41.jar
  - file:/E:/android/adt-bundle-windows-x86-20130917/sdk/extras/android/m2repository/org/jetbrains/kotlin/kotlin-reflect/1.2.41/kotlin-reflect-1.2.41.pom
  - file:/E:/android/adt-bundle-windows-x86-20130917/sdk/extras/android/m2repository/org/jetbrains/kotlin/kotlin-reflect/1.2.41/kotlin-reflect-1.2.41.jar
  - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-reflect/1.2.41/kotlin-reflect-1.2.41.pom
  - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-reflect/1.2.41/kotlin-reflect-1.2.41.jar
Required by:
    project : > com.android.tools.lint:lint-gradle:26.3.0-alpha05
    project : > com.android.tools.lint:lint-gradle:26.3.0-alpha05 > com.android.tools:sdk-common:26.3.0-alpha05
    project : > com.android.tools.lint:lint-gradle:26.3.0-alpha05 > com.android.tools.lint:lint:26.3.0-alpha05
    project : > com.android.tools.lint:lint-gradle:26.3.0-alpha05 > com.android.tools.lint:lint-gradle-api:26.3.0-alpha05
    project : > com.android.tools.lint:lint-gradle:26.3.0-alpha05 > com.android.tools.lint:lint:26.3.0-alpha05 > com.android.tools.lint:lint-kotlin:26.3.0-alpha05
    project : > com.android.tools.lint:lint-gradle:26.3.0-alpha05 > com.android.tools.lint:lint:26.3.0-alpha05 > com.android.tools.lint:lint-checks:26.3.0-alpha05 > com.android.tools.lint:lint-api:26.3.0-alpha05

There were also all sorts of errors that couldn't be resolved, and later the gradle version was lowered (4.9,build:gradle:3.5.0-alpha50) to a lower version of 4.5,

classpath 'com.android.tools.build:gradle:3.1.4',

In this way, to restart the sync project, it's amazing to type the release package, so click on my profile:

   (1)build.gradle

buildscript {
    ext.kotlin_version='1.2.41'
    repositories {
        jcenter()
        google()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

dependencies {
    compile fileTree(include: '*.jar', dir: 'libs')
}

android {
    compileSdkVersion 26
    buildToolsVersion "27.0.3"

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            jniLibs.srcDirs = ['libs']
        }

        // Move the tests to tests/java, tests/res, etc...
        //instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

repositories {
    google()
}

(2) File contents of gradle-wrapper.properties:

#Mon Aug 13 17:54:14 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip

Yes, you will encounter lint errors when typing release packages. The message window will prompt you with the solution: just add:

lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }

 

At this point, the eclipse android project has been successfully completed by android studio. It can only be said that gradle is a pit in things. Some errors can not find the problem. Record them so that people can easily encounter the same errors for reference.

Keywords: Android Gradle Eclipse Google

Added by lajocar on Tue, 14 May 2019 19:19:56 +0300