eclipse工程手动迁移android-studio

----------------------------------------------------------------------- 方法一 ------------------------------------------------------------

一、迁移src

  直接拷贝eclipse中src/com到AS中的src/main/java中。

二、迁移AndroidManifest.xml  

         直接复制eclipse的AndroidManifest.xml到AS的src/main目录中。

三、迁移图片等文件。

  直接将eclipse的图片、风格文件复制到AS的src/main/res目录中。

四、复制*.jar

  将eclipse的libs目录中的文件复制到AS的libs目录下。

五、复制*.so

  将eclipse的libs/armeabi目录复制到AS的src/main/jniLibs目录下,若没有,则创建。

六、混淆文件添加

  在build.gradle中进行配置

  android {

                       buildTypes {

                                     release {             

                                                        minifyEnabled true

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

                                                  //proguardFile 'some-other-rules.txt'  配置单个文件这样

                                                    }

                                      }  

                          }  

          如上面代码所示,我们可以使用minifyEnabled true开启,并且对其配置混淆配置,可以配置多个文件或单个文件。

   android的sdk中已经为我们提供了两个默认的配置文件,我们可以拿过来进行使用,proguard-android.txt和proguard-android-optimize.txt。


七、添加assets

/src/main/assets




错误:

1、Error:Execution failed for task ':equipmenttesting:transformClassesWithDexForDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/opt/jdk1.8.0_65/bin/java'' finished with non-zero exit value 1

    解决:检查引用的包是否重复了。


----------------------------------------------------------------------- 方法二 ------------------------------------------------------------

将如下build.gradle拷贝到eclipse目录下,用android studio打开build.gradle ,加载完毕即可,过程中可能出现gradle不匹配,只要按需求更新下就好。


repositories {
    jcenter()
    flatDir {
        dirs 'libs'
    }
}
//添加以下代码,使classes-full-debug.jar包编译先于android.jar
gradle.projectsEvaluated {
    tasks.withType(JavaCompile) {
        options.compilerArgs.add('-Xbootclasspath/p:libs/framework.jar')
    }
}


buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
    }
}

apply plugin: 'com.android.application'


dependencies {
    compile fileTree(include: '*.jar', dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.1.0'
    provided files('libs/framework.jar')
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.android.support:multidex:1.+'
    compile 'uk.co.chrisjenx:calligraphy:2.2.0'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    compile 'com.jakewharton:butterknife:5.1.1'
    compile project(':chargerlib')
}

android {
    compileSdkVersion 23
    buildToolsVersion '25.0.0'
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 20
        multiDexEnabled true
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
    //证书信息在这里配置
    signingConfigs {
        main {
            storeFile file("./platform.jks")
            storePassword "atsmart123"
            keyAlias "atsmart"
            keyPassword "atsmart123"
        }
    }
 
    lintOptions {
	//表示不进行lint检测
        checkReleaseBuilds false
        //表示检测出错不退出
	abortOnError false
    }
    //编译类型
    buildTypes {
        // 发布版
        release {
            //     minifyEnabled false
            // proguardFiles getDefaultProguardFile('proguard-project.txt'), 'proguard-rules.pro'

            signingConfig signingConfigs.main
        }
        //工程版
        debug {
            minifyEnabled false
            // proguardFiles getDefaultProguardFile('proguard-project.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.main
            // manifestPlaceholders = [myid:"android.uid.system"]
        }
    }

    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')
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值