欢迎大家来到IT世界,在知识的湖畔探索吧!
Android Eclipse项目变更为Android Studio项目的步骤和通用模板
1.先用Android Studio新建一个与原来项目名称一样空白的项目,如com.xxx.yyy
2.Eclipse项目res目录复制到app\src\main\res(values-v11,values-v14,values-w820dp不要复制)
3.Eclipse项目的src目录下的代码文件复制到app\src\main\java\com\xxx\yyy
4.Eclipse项目的AndroidManifest.xml替换AndroidManifest.xml,同时去掉VersionCode VersionName的内容,以及含有类似如下的内容:
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="21" />
欢迎大家来到IT世界,在知识的湖畔探索吧!
5..Eclipse项目的libs下面的库复制到\app\libs(不复制android-support-v4.jar)
6.Android Studio项目在proguard-rules.pro增加要混淆的规则
7.Android Studio项目下的build.gradle(Project)修改:比如添加如下内容:
buildscript {
repositories {
maven{ url ‘http://maven.aliyun.com/nexus/content/groups/public/’}
maven { url ‘https://dl.bintray.com/umsdk/release’ }
google()
mavenCentral()
jcenter{url “http://jcenter.bintray.com/”}
}
dependencies {
classpath ‘com.android.tools.build:gradle:3.2.1’
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven{ url ‘http://maven.aliyun.com/nexus/content/groups/public/’}
maven { url ‘https://dl.bintray.com/umsdk/release’ }
google()
//mavenCentral()
jcenter{url “http://jcenter.bintray.com/”}
maven { url “https://jitpack.io” }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
8.Android Studio项目\app下的build.gradle(Module)修改,比如:
apply plugin: ‘com.android.application’
android {
compileSdkVersion 26
useLibrary ‘org.apache.http.legacy’
defaultConfig {
applicationId “com.xxx.yyy”
minSdkVersion 18
targetSdkVersion 26
versionCode 100
versionName “1.00”
testInstrumentationRunner “android.support.test.runner.AndroidJUnitRunner”
ndk {
//选择要添加的对应cpu类型的.so库。
abiFilters ‘armeabi’, ‘armeabi-v7a’, ‘arm64-v8a’, ‘x86’, ‘x86_64’
}
}
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
}
buildTypes {
debug {
// 显示Log
buildConfigField “boolean”, “LOG_DEBUG”, “true”
versionNameSuffix “-debug”
minifyEnabled false
zipAlignEnabled false
shrinkResources false
signingConfig signingConfigs.debug
}
release {
// 不显示Log
buildConfigField “boolean”, “LOG_DEBUG”, “false”
//混淆
minifyEnabled true
//Zipalign优化
zipAlignEnabled true
// 移除无用的resource文件
shrinkResources true
//前一部分代表默认的android程序的混淆文件,该文件已经包含了基本的混淆声明,后一个文件是自己的定义混淆文件
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’
}
}
}
dependencies {
implementation fileTree(include: [‘*.jar’], dir: ‘libs’)
implementation ‘com.android.support.constraint:constraint-layout:1.1.3’
testImplementation ‘junit:junit:4.12’
implementation ‘com.android.support:support-annotations:28.0.0’
//androidTestImplementation ‘com.android.support.test:runner:1.0.2’
androidTestImplementation ‘com.android.support.test.espresso:espresso-core:3.0.2’
implementation ‘com.umeng.umsdk:analytics:7.5.4’
implementation ‘com.umeng.umsdk:common:1.5.4’
implementation ‘com.android.support:appcompat-v7:25.3.1’
implementation ‘com.android.support:recyclerview-v7:25.3.1’
}
8.常见错误排除:
(1)Output: F:\AS\AndroidStudioProject\bmicalculator\app\src\main\res\menu\main.xml:6: error: attribute showAsAction (aka com.zmcorp.bmicalculator:showAsAction) not found.
error: failed linking file resources.
解决办法:menu\main.xml删除如下行:
欢迎大家来到IT世界,在知识的湖畔探索吧!app:showAsAction="never"
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://itzsg.com/36776.html