android studio3.0新建类,升级到AndroidStudio3.0 之后的遇到问题的处理(新建、方法数限制等)...

引言:

遇到的新问题:

1,新建项目报错:

Unable to resolve dependency for :app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.;

Unable to resolve dependency for :constraint-layout: Could not resolve constraint-layout:1.0.2;

处理bug

1.1处理constraint-layout:1.0.2无法依赖的问题:

setting->System setting->android SDK->SDK Tools 最下面关于

constraint-layout的依赖都导入;

bVYMqw?w=1297&h=720

1.2处理其他无法依赖,在build.gradle文件中

1.2.1 appcompat-v7:26.1.0修改

implementation 'com.android.support:appcompat-v7:26.1.0'

改为

implementation 'com.android.support:appcompat-v7:26.+'

androidTestImplementation

1.2.2 espresso-core修改

'com.android.support.test.espresso:espresso-core:3.0.1'

改为

androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'

1.2.3 runner修改 androidTestImplementation 'com.android.support.test:runner:1.0.1'

改为

androidTestImplementation 'com.android.support.test:runner:0.4'

1.3 总体修改bug如下:

dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'com.android.support:appcompat-v7:26.+'

implementation 'com.android.support.constraint:constraint-layout:1.0.2'

testImplementation 'junit:junit:4.12'

androidTestImplementation 'com.android.support.test:runner:0.4'

androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'

}

2,如果项目被android3.0编译过,重新用AS3.0以下的AS打开会报错如下:

Error:Jack is required to support java 8 language features. Either enable Jack or

remove sourceCompatibility JavaVersion.VERSION_1_8

需要在

defaultConfig {

applicationId "com.xxx"

minSdkVersion 19

targetSdkVersion 24

versionCode 1

versionName "1.0"

jackOptions {

enabled true

}

}

需要添加

jackOptions {enabled true}

3,AS3.0超过方法数设置处理

以前如果遇超过方法数超过65535的解决办法一般是defaultConfig 中添加

multiDexEnabled true

dependencies {

compile 'com.android.support:multidex:1.0.0'

}

Application 类重写方法:

@Override

protected void attachBaseContext(Context base) {

super.attachBaseContext(base);

MultiDex.install(this);

}

现在AS3.0好像没有这个限制 com.android.support:multidex:1.0.0这个包也无法依赖,把依赖包、multiDexEnabled true、application中的东西全部删除就可以正常运行;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值