How do you set APP_PLATFORM in Gradle NDK plug-in in Android Studio? - android-studio

I'm building an app with an NDK library using Android Studio 1.5.1 and the Gradle experimental plugin 0.4.0.
Even though the Gradle config is set as such (with minSdkVersion.apiLevel = 18), it seems like the NDK library is still compiled for android-21:
compileOptions.with {
sourceCompatibility=JavaVersion.VERSION_1_7
targetCompatibility=JavaVersion.VERSION_1_7
}
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.2"
defaultConfig.with {
applicationId = "net.pol_online.hyper"
minSdkVersion.apiLevel = 18 // Android 4.3 Jelly Bean
targetSdkVersion.apiLevel = 23 // Android 6.0 Marshmallow
}
}
Is it because APP_PLATFORM is not automatically set by the Gradle NDK support based on the min SDK version? If so how do you fix this?

You can set this:
android.ndk {
platformVersion = "19"
}
See https://stackoverflow.com/a/33982735/3115956 for details on this. (In practice, I think your library is built targeting android-23, which has the same effect as targeting android-21 - compileSdkVersion is the one that affects it (for both the java and native code, unless the native one is overridden).

Related

arm64-v8a Build Variant not showing up in Android Studio

How can I make arm64-v8a show up in Build Variant section?
I'm using the following setup on macOS:
Android Studio 3.4.1
Gradle Version 3.3
android-ndk-r15c
compileSdkVersion = 25
put this code in build gradle
splits {
abi {
enable true
reset()
include "x86", "armeabi-v7a", "arm64-v8a", "x86_64"
}
}
Documentation

How to detect Android Gradle dependencies that have newer versions available?

I manage my Android app and associated modules Gradle dependencies using Gradle ext{} variables.
for example
ext {
compileSdkVersion = 28
targetSdkVersion = 28
minSdkVersion = 21
buildToolsVersion = "28.0.3"
supportLibVersion = '1.0.2'
coreKtx = '1.0.2'
materialMaterial = "1.0.0"
legacySupportV4 = "1.0.0"
recyclerView = "1.0.0"
lifecycleExtensions = "2.0.0"
playServicesAuthVersion = "16.0.1"
archLifecycleVersion = '2.0.0'
roomVersion = '2.1.0-beta01'
archPagingVersion = '2.1.0'
archWorkerRuntimeVersion = "1.0.1"
constraintLayoutVersion = '1.1.3'
browserVersion = '1.0.0'
appCompatVersionXXX = '1.1.0-alpha03'
appCompatVersion = '1.0.2'
...
Android studio "sometimes" highlights a dependency where a newer version is available, however this doesn't appear to be consistent.
I've tried using Android Studio Analyze > Run Inspection by Name > Newer Library Versions Available, however that doesn't work at all.
The version of Android Studio is
Android Studio 3.4
Build #AI-183.5429.30.34.5452501, built on April 10, 2019
JRE: 1.8.0_152-release-1343-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.14.4
How can I detect out of date library versions in Android Studio consistently?
Hector,
Android Studio 3.4 has this screen where you can see updated version of your dependency.
Go to File -> Project Structure -> Select Dependencies
In this section, if you see a gray color underline in any dependencies name, that means it has a new update as said above.Update Underline

How to fix "Unable to load class 'com.android.builder.errors.EvalIssueReporter'." error on Android Studio 3.2.1

I use IntelliJ IDEA for creating #Flutter projects and I have the Android Studio for installation purposes of Flutter onto my machine. The problem arose when I upgraded the Android Studio from 3.1.4 to 3.2.1. Moreover, after this upgrade, I'm no longer able to create any project in both IDEs.
The error message in IntelliJ
The error message in Android Studio
P.S. Those are the default programs of both IDEs namely, IntelliJ and Android Studio.
any newly-created project brings up this error; however, previously-created projects work perfectly fine.
My machine has 64-bit OS, x64-based Processor
IntelliJ
IntelliJ IDEA 2018.3.3 (Community Edition)
Build #IC-183.5153.38, built on January 9, 2019
JRE: 1.8.0_152-release-1343-b26 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
Android Studio
Android Studio 3.2.1
Build #AI-181.5540.7.32.5056338, built on October 9, 2018
JRE: 1.8.0_152-release-1136-b06 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
project's build.gradle file:
// Top-level build file where you can add configuration options common to
all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
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 {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
the individual module build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.nonna.myapplication"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.2'
}
I have checked those questions but unfortunately, the error wasn't fixed.
Build errors after Android Studio 3.2.1 upgrade
Could not find com.android.tools.build:aapt2:3.2.0
This issue got solved and now the IDE is working like a charm.
As it was seen from the provided screenshots there was an error in the Android Gradle plugin, so to solve this issue follow the numbered steps in the newly provided screenshots below.
(Part 1) Solving gradle issue due to upgrading Android Studio to 3.2.1
Step 0: From the left panel in your IDE, choose the android
[name_of_project] folder
Step 1: look for the build.gradle file then double click it to
start editing it
Step 2: change exactly the line that states
classpath
'com.android.tools.build:gradle:3.2.1' to the current version of
your Android Studio, in other terms, classpath
'com.android.tools.build:gradle:3.3.0' in my case.
(Part 2) Solving gradle issue due to upgrading Android Studio to 3.2.1
Step 3: After finishing from Steps 1 & 2, go to the gradle folder
Step 4: Double click on the wrapper subfolder
Step 5: Click the gradle-wrapper.properties file to start editing
it
Step 6: make sure that your gradle version is compatible with your
current Android Studio
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
The Android Gradle plugin 3.3.0 requires the Gradle version of 4.10.1 and newer.
Disclaimer: you need to do these steps whenever you create a new project on whatever IDE you use namely, Android Studio, IntelliJ IDEA, and VS Code.

Renderscript error in Android Studio 2.0 stable

I updated Android Studio to 2.0 stable, then I got this error:
Renderscript support mode is not currently supported with renderscript
target 21+
What should i do?
tnx
This has been fixed in gradle-plugin 2.1.0 and Build-Tools 23.0.3.
Use the code below:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
...
}
Renderscript isn't currently supported with Target 21+ so simply change the target to below API 20 and that error will be solved.
replace your code with below code:
renderscriptTargetApi 20
renderscriptSupportModeEnabled true

Android Studio Google Maps API v2

i'm trying to use Google Maps API v2 in my project.
This is my environment:
OSX 10.9
Android Studio 0.3.2
min SKD 9 and compile SDK 14
Java 1.7.0_17
Testing on Nexus 7 4.3 with GooglePlayService 4.0.30
I get the following errors on the device. Android Studio don‘t note any errors:
11-05 07:44:33.888 2386-2386/myproject E/dalvikvm﹕ Could not find
class 'com.google.android.gms.maps.SupportMapFragment', referenced from method
myproject.activities.Maps.initMaps
11-05 07:44:34.052 2386-2386/myproject E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.google.android.gms.common.GooglePlayServicesUtil
at myproject.activities.Maps.onResume(Maps.java:36)
The error point is clear: There are missing class files.
Here are the dependencies of my project:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 14
buildToolsVersion "18.1.1"
defaultConfig {
minSdkVersion 9
targetSdkVersion 10
}
}
dependencies {
compile 'com.android.support:appcompat-v7:18.0.+'
compile 'com.android.support:gridlayout-v7:18.0.+'
compile 'com.android.support:support-v4:19.0.+'
compile 'com.android.support:support-v13:19.0.+'
compile 'com.google.android.gms:play-services:4.0.30'
}
In my opinion should be compile 'com.google.android.gms:play-services:4.0.30' enough.
So any suggestions what's missing ?
Greetz,
Moddus
I had the same problem.
When I changed the version to 'com.google.android.gms:play-services:3.1.36' my app started normally without any errors but the map was white.
Tried several diferent api keys and still don't know where the problem is...
edit: Finally I made my app to shows up the map by changing the classpath of the buildsctipt. I'm using Android Studio v.0.4 which comes with gradle:0.7 and I gess it has a problems for now with google play services. Here is my build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
}
}
dependencies {
compile 'com.google.android.gms:play-services:3.1.36'
compile 'com.android.support:appcompat-v7:+'
}

Resources