只有从android 0 --min-api 26开始才支持Invoke-customs

时间:2018-04-18 05:22:08

标签: android android-studio android-gradle

在我使用构建版本gradle 26之前,但是 将buildtoolsversion改为27就像这个图像一样 错误: 错误构建gradle屏幕截图

5 个答案:

答案 0 :(得分:614)

经过几个小时的挣扎,我通过在 app / build.gradle 中包含以下内容解决了这个问题:

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

https://github.com/mapbox/mapbox-gl-native/issues/11378

答案 1 :(得分:35)

如果compileOptions不起作用,请尝试

禁用“即时运行”。

Android Studio->文件->设置->构建,执行,部署->即时运行->禁用复选框

答案 2 :(得分:17)

在我的情况下,错误仍然存​​在,因为我的系统使用升级的Java。 如果您使用的是Java 10,请修改compileOptions:

state = {
   value: "",
   unit: "Kgs"
}
render(){
   return(
     <View style={{flexDirection: 'row', alignItems: 'center'}} >
            <TextInput value={this.state.value} onChangeText={(value) => this.setState({value})} />
            <View style={{marginRight: 10}} >
                <Text>{this.state.value === '' ? '' : this.state.unit}</Text>
            </View>
     </View>       
   );
}

答案 3 :(得分:13)

如果您具有Java 7,请在应用级build.gradle中包含以下代码段:

compileOptions {

    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7

}

答案 4 :(得分:0)

realm.io更新为使用版本5.8.0 版本5.9.0