Android Studio升级到3.3.2之后编译遇到的问题

问题一:No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

因为我的NDK也升级到了最新的版本,所以在查了一些资料后发现,在NDK的changelog中,官方已经给了说明

This version of the NDK is incompatible with the Android Gradle plugin version 3.0 or older. If you see an error like No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android, update your project file to use plugin version 3.1 or newer. You will also need to upgrade to Android Studio 3.1 or newer.

所以解决方案很简单,在你的项目级的build.gradle中,升级gradle插件版本(我这里之前是3.0.1):

buildscript {  
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
    }
}

这个报错,build的时候错误的下边一般会直接给出这样的一个解决方案,点击就可以了!

问题二:Android resource linking failed

这个报错的日志如下:

app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:946: error: resource android:attr/fontVariationSettings not found.
app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:946: error: resource android:attr/ttcIndex not found.
error: failed linking references.

这个错误具体原因,在查了一些资料之后,感觉还不是太清楚!这里先给出解决方案吧!
在Stack Overflow上找到一个回答:
error9-5-error-resource-androidattr-dialogcornerradius-not-found

我这里就是将compileSdkVersion升级到28

compileSdkVersion: 28,
buildToolsVersion: "28.0.3"

另外,相对应的support依赖,比如design,appcompat也改成28的版本

问题三:save() in Canvas cannot be applied to (int)

代码中下边这一句报错:

canvas.save(Canvas.ALL_SAVE_FLAG)

查看源码:

/**
     * Based on saveFlags, can save the current matrix and clip onto a private
     * stack.
     * <p class="note"><strong>Note:</strong> if possible, use the
     * parameter-less save(). It is simpler and faster than individually
     * disabling the saving of matrix or clip with this method.
     * <p>
     * Subsequent calls to translate,scale,rotate,skew,concat or clipRect,
     * clipPath will all operate as usual, but when the balancing call to
     * restore() is made, those calls will be forgotten, and the settings that
     * existed before the save() will be reinstated.
     *
     * @removed
     * @deprecated Use {@link #save()} instead.
     * @param saveFlags flag bits that specify which parts of the Canvas state
     *                  to save/restore
     * @return The value to pass to restoreToCount() to balance this save()
     */
    public int save(@Saveflags int saveFlags) {
        return nSave(mNativeCanvasWrapper, saveFlags);
    } 

已经被removed了,使用save()方法代替!
所以这里去掉参数saveFlag即可:

canvas.save()

参考文章:
Android Studio升级3.2以后 Androidx 异常总结

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值