Plugin with id 'com.android.model.native' not found - android

I am trying to develop a module from my C project with Android Studio. I am having the problem of
Plugin with id 'com.android.model.native' not found.
What did I do wrong?
Thank you!
Below is the App level build.gradle
apply plugin: "com.android.model.native"
model {
android {
compileSdkVersion 27
defaultConfig {
applicationId = 'com.example.androidthings.nativepio'
minSdkVersion 27
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
ndk {
//platformVersion = "21"
moduleName "libusb"
ldLibs.addAll(["log"])
CFlags.add("-Wall")
CFlags.add("-I" + file("src/main/jni/android").absolutePath)
CFlags.add("-O3")
}
sources {
main {
jni {
exportedHeaders {
srcDir "src/main/jni/libusb"
}
dependencies {
project ":dependency_module"
}
}
}
}
}
}
Here is the project level build gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

This plugin was part of an experimental and old version of the current build system.
You should rewrite your gradle file to work with the current build system. Either let Android Studio generate the necessary additions by linking to your CMake file, or copy from a known-good sample like the HelloJNI sample:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
ndkVersion '21.2.6472646'
defaultConfig {
applicationId 'com.example.hellojni'
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
buildFeatures {
viewBinding true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
}
}
flavorDimensions 'cpuArch'
productFlavors {
arm8 {
dimension 'cpuArch'
ndk {
abiFilters 'arm64-v8a', 'armeabi-v7a'
}
}
x86_64 {
dimension 'cpuArch'
ndk {
abiFilters 'x86_64', 'x86'
}
}
universal {
dimension 'cpuArch'
// include all default ABIs. with NDK-r16, it is:
// armeabi-v7a, arm64-v8a, x86, x86_64
}
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

Related

Allow insecure protocols, android gradle, aliyun maven

When I download a new android project from git, I met this problem:
Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven(http://maven.aliyun.com/nexus/content/repositories/jcenter)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.3.3/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details.
In addition, I've viewed this blog without an answer. Because I have found no 'aliyun' maven usage in the project by 'Search Everywhere' and 'Find In Path' .You can see my problem in the follow picture.
details
search res
project root path
settings.gradle:
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url "https://jcenter.bintray.com" }
maven { url "https://jitpack.io" }
}
}
rootProject.name = "viewer"
include ':app', ':daogenerator'
project root path
build.gradle
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'com.google.gms.google-services' version '4.3.10' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
module app
build.gradle
apply plugin: 'com.android.application'
if (file('google-services.json').exists()) {
apply plugin: 'com.google.gms.google-services'
// apply plugin: 'io.fabric'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
ndkVersion '23.1.7779620'
flavorDimensions "distribute"
productFlavors {
appCenter {
dimension "distribute"
}
googlePlay {
dimension "distribute"
}
}
defaultConfig {
applicationId "com.xjs.viewer"
minSdkVersion 23
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 29
versionCode 111
versionName "1.9.4.2"
vectorDrawables.useSupportLibrary = true
resConfigs "zh", "zh-rCN", "zh-rHK", "zh-rTW",
"es", "ja", "ko", "fr", "de", "th"
testOptions.unitTests.includeAndroidResources = true
ndk {
moduleName "native-lib"
abiFilters "armeabi-v7a" , "arm64-v8a", "x86", "x86_64"
}
externalNativeBuild {
cmake {
cppFlags ''
}
}
}
lint {
disable 'MissingTranslation'
abortOnError true
checkReleaseBuilds true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField 'String', 'FILE_PROVIDER_AUTHORITY', '"com.hippo.viewer.fileprovider"'
}
debug {
applicationIdSuffix ".debug"
buildConfigField 'String', 'FILE_PROVIDER_AUTHORITY', '"com.hippo.viewer.debug.fileprovider"'
}
}
externalNativeBuild {
cmake {
path file('src/main/cpp/CMakeLists.txt')
}
}
sourceSets {
main {
java.srcDirs += 'src/main/java-gen'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
buildFeatures {
viewBinding true
}
}
task copyNotice(type: Copy) {
from '../NOTICE.html'
into './src/main/assets'
finalizedBy ":daogenerator:executeDaoGenerator"
}
tasks.withType(JavaCompile) {
task -> task.dependsOn copyNotice
}
clean {
delete file('src/main/assets/NOTICE.html').absolutePath
}
dependencies {
......
}
configurations.all {
resolutionStrategy {
.......
}
}
Please help me./(ㄒoㄒ)/~~
updated my gradle version to 7.3.3.
I finally solved it by updata Android Studio to newest version....
I don't know what happend definitely.

How to config top level build.gradle file of chatsecure to override other build.gradles?

I use this library and want to increase targetSdkVersion to 24 and want to make this change by adding to top level build.gradle file how can I do this?
I changed build.gradle file to this, but it gives me: cannot find AndroidManifest
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '24.0.2'
defaultConfig {
minSdkVersion 9
targetSdkVersion 24
versionCode 1411005
versionName "14.1.1-RC-5"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
}
}
allprojects {
repositories {
jcenter()
}
}
Add Top-level build file where you can add configuration options common to all sub-projects/modules.
Add following in build.gradle(project root) file.
ext {
configuration = [
appName : "app_Name",
applicationId : "com.xx.xxx.app",
minSdkVersion : 14,
targetSdkVersion : 24,
compileSdkVersion: 24,
versionCode : 6,
versionName : "1.3.6",
buildToolsVersion: "23.0.3",
]
libraries = [
supportVersion: "24.2.1"
]
}
In modules
def appConfig = rootProject.ext.configuration;
def libs = rootProject.ext.libraries;
dependencies {
compile project(':multiselect')
compile "com.android.support:appcompat-v7:${libs.supportVersion}"
}
For example
Root gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
ext {
configuration = [
appName : "app name",
applicationId : "com.xx.xx.app",
minSdkVersion : 14,
targetSdkVersion : 24,
compileSdkVersion: 24,
versionCode : 6,
versionName : "1.3.6",
buildToolsVersion: "23.0.3",
]
libraries = [
supportVersion: "24.2.1"
]
}
buildscript {
repositories {
jcenter() // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
task checkstyle(type: Checkstyle) {
showViolations = true
configFile file("../config/checkstyle/checkstyle.xml")
source 'src/main/java'
include '**/*.java'
exclude '**/gen/**'
exclude '**/R.java'
exclude '**/BuildConfig.java'
// empty classpath
classpath = files()
}
}
task clean(type: Delete) {
delete(rootProject.buildDir)
}
App Gradle
apply plugin: 'com.android.application'
apply plugin: 'checkstyle'
def appConfig = rootProject.ext.configuration;
def libs = rootProject.ext.libraries;
android {
compileSdkVersion appConfig.compileSdkVersion
buildToolsVersion appConfig.buildToolsVersion
defaultConfig {
applicationId appConfig.applicationId
minSdkVersion appConfig.minSdkVersion
targetSdkVersion appConfig.targetSdkVersion
versionCode appConfig.versionCode
versionName appConfig.versionName
signingConfig signingConfigs.config
}
buildTypes {
release {
}
debug {
}
}
productFlavors {
}
}
dependencies {
compile project(':multiselect')
compile "com.android.support:appcompat-v7:${libs.supportVersion}"
compile "com.android.support:cardview-v7:${libs.supportVersion}"
compile "com.android.support:recyclerview-v7:${libs.supportVersion}"
compile "com.android.support:design:${libs.supportVersion}"
}
Module Gradle
apply plugin: 'com.android.library'
def appConfig = rootProject.ext.configuration;
def libs = rootProject.ext.libraries;
android {
compileSdkVersion appConfig.compileSdkVersion
buildToolsVersion appConfig.buildToolsVersion
defaultConfig {
minSdkVersion appConfig.minSdkVersion
targetSdkVersion appConfig.targetSdkVersion
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile "com.android.support:appcompat-v7:${libs.supportVersion}"
compile "com.android.support:design:${libs.supportVersion}"
}
For more about Configure Your Build
You can also try this.
TOP level build gradle
ext {
androidCompileSdkVersion = 25
androidBuildToolsVersion = '25.0.1'
androidMinSdkVersion = 14
androidTargetSdkVersion = 25 }
ext {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
supportLibraryVersion = '25.0.1'
retrofitVersion = '2.3.0'
okhttpVersion = '3.6.0'
parcelerApiVersion = '1.1.9'
daggerVersion = '2.5'
butterknifeVersion = '8.7.0'
dependencies = [
appCompat : "com.android.support:appcompat-v7:$supportLibraryVersion",
recyclerView : "com.android.support:recyclerview-v7:$supportLibraryVersion",
cardView : "com.android.support:cardview-v7:$supportLibraryVersion",
designSupport: "com.android.support:design:$supportLibraryVersion",
support : "com.android.support:support-v4:$supportLibraryVersion",
retrofit :
"com.squareup.retrofit2:retrofit:$retrofitVersion",
retrofitConverterGson: "com.squareup.retrofit2:converter-gson:$retrofitVersion",
retrofitAdapterRxJava: "com.squareup.retrofit2:adapter-rxjava:$retrofitVersion",
retrofitLogging : "com.squareup.okhttp3:logging-interceptor:$okhttpVersion",
rxAndroid : 'io.reactivex.rxjava2:rxandroid:2.0.1',
rxJava : 'io.reactivex.rxjava2:rxjava:2.1.0',
rxBinding : 'com.jakewharton.rxbinding:rxbinding:0.4.0',
butterknife : "com.jakewharton:butterknife:$butterknifeVersion",
butterknifecompiler : "com.jakewharton:butterknife-compiler:$butterknifeVersion",
] }
APP level build gradle
android {
compileSdkVersion rootProject.ext.androidCompileSdkVersion
buildToolsVersion rootProject.ext.androidBuildToolsVersion
defaultConfig {
applicationId "com.developerandroid"
minSdkVersion rootProject.ext.androidMinSdkVersion
targetSdkVersion rootProject.ext.androidTargetSdkVersion
versionCode 1
versionName "1.0"
}
packagingOptions {
exclude 'META-INF/rxjava.properties'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
Map<String, String> dependencies = rootProject.ext.dependencies
//support
compile dependencies.appCompat
compile dependencies.recyclerView
compile dependencies.cardView
compile dependencies.designSupport
compile dependencies.support
// retrofit
compile dependencies.retrofit
compile dependencies.retrofitConverterGson
compile dependencies.retrofitLogging
compile dependencies.retrofitAdapterRxJava
// rx
compile dependencies.rxJava
compile dependencies.rxAndroid
compile dependencies.rxBinding
}

buildToolsVersion is not specified, all "apply plugin: xxxx " is in app/build.gradle

my module build.gradle
apply plugin: 'com.android.application'
model {
android {
// 编译SDK的版本
compileSdkVersion = 23
// build tools的版本
buildToolsVersion = "23.0.3"
//useLibrary = 'org.apache.http.legacy'
defaultConfig.with {
// 应用的包名
applicationId = "com.example.administrator.design"
minSdkVersion.apiLevel = 15
targetSdkVersion.apiLevel = 23
versionCode = 1
versionName = "1.0"
}
tasks.withType(JavaCompile) {
//指定编译JDK版本
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
}
android.ndk {
moduleName = "test"
ldLibs += "log"
abiFilters += "armeabi"
abiFilters += "armeabi-v7a"
abiFilters += "x86"
}
android.productFlavors {
create("arm7") {
ndk.abiFilters.add("armeabi-v7a")
}
create("arm8") {
ndk.abiFilters.add("arm64-v8a")
}
}
android.buildTypes {
release {
// 是否进行混淆
minifyEnabled = false
// 混淆文件的位置
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles += file('proguard-android.txt')
proguardFiles += file('proguard-rules.pro')
//resValue "string", "facebook_app_id", '"597651723652854"'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
//testCompile 'junit:junit:4.12'
compile 'org.xutils:xutils:3.3.20'
...
}
my project build.gradle
buildscript {
repositories {
jcenter()
//mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle wrapper
#Mon Mar 28 16:31:26 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
if I use "com.android.tools.build:gradle:0.20" in project build.gradle, and make some according changes it just works fine, But I want the new feature instant, run I have googled almost one afternoon.
Looks like you used an experimental gradle plugin version. The stable version 2.0.0 and the experimental version have some differences regarding the notation in the build.gradle file.
For example the android block needs to be outside the model block. And some attribute specifications are slightly different. Have a look at the Experimental Gradle Plugin User Guide, especially the red highlighted parts in the build.gradle example file.
Also I'm not really sure, but the non-experimental version still doesn't have full NDK support. Although it looks like the experimental version 0.6 does support the NDK as well as Instant Run, so you might use the version 0.6 instead of 2.0.

Cannot make Android databinding plugin work

I am trying to make use of the android databinding plugin with no luck so far.
I am using: Gradle 2.2.1; Intellij IDEA 15.
Project level build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath "com.android.databinding:dataBinder:1.0-rc2"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Module build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
buildscript {
repositories {
jcenter()
}
dependencies {
}
}
repositories {
jcenter()
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.app4.app4"
minSdkVersion 10
targetSdkVersion 10
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
}
I got few different errors while trying to change plugins' versions; the error I am getting now is "Error:Gradle: A problem occurred configuring project ':app4'.
Failed to notify project evaluation listener.
android.databinding.tool.LayoutXmlProcessor.(Ljava/lang/String;Landroid/databinding/tool/writer/JavaFileWriter;IZLandroid/databinding/tool/LayoutXmlProcessor$OriginalFileLookup;)V"
With the new version of the data binding library, you don't explicitly add the databinding dependency then apply it. All you need is dataBinding{enabled = true;} Other concerns: your target SDK version should probably not be 10 at this point.
Example:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
allprojects {
repositories {
jcenter()
}
}
and
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.yourappname"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true;
}
}
dependencies {
//other dependencies
}
I don't recall if the neenbedankt gradle plugin is strictly necessary, but it's very useful for compile time annotation processing.

Experimental NDK Support on Android Studio

I have experience with Android development on Eclipse, but I'm quite new to this gradle stuff.
I created a project on Android Studio and tried adding native library support. I followed the documents on android.com
Android NDK Preview
Experimental Plugin User Guide
I bumped into the following problem and I'm not even familiar with the terminology! It says: Unable to load class 'com.android.build.gradle.managed.ProductFlavor_Impl'
Suggestions did not solve the problem. How can I solve it?
Here are the contents of the build.gradle and app/build.gradle:
build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.2.0'
}
}
allprojects {
repositories {
jcenter()
}
}
app/build.gradle
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.0"
defaultConfig.with {
applicationId = "com.example.wofm"
minSdkVersion = 15
targetSdkVersion = 23
versionCode = 1
versionName = "1.0"
}
}
android.ndk {
moduleName = "wofmUtil"
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles = getDefaultProguardFile('proguard-android.txt')
proguardFiles += 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
}
You should use minSdkVersion.apiLevel and targetSdkVersion.apiLevel instead of minSdkVersion and targetSdkVersion. And I also had a problem with getDefaultProguardFile() so I had to remove it.

Categories

Resources