tns run android with a specific sdk - nativescript

I just created a new application and added android platform. Since I failed to install API 28 for days, I want to run the project against the working SDK 21. How can I configure the application to run with sdk 21?
My app/App_resources/android/app.gradle is the default one with:
android {
defaultConfig {
generatedDensities = []
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
in platforms/android/.gradle/ I see 4.10.2
while my build.gradle is:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
When i run tns run android --emulator
the message is:
Gradle build...
+ setting applicationId
+ applying user-defined configuration from D:\pyworks\agrigo7\mobileapp\agrigo\app\App_Resources\Android\app.gradle
Using support library version 28.0.0
+ adding nativescript runtime package dependency: nativescript-optimized-with-inspector
+ adding aar plugin dependency: D:\pyworks\agrigo7\mobileapp\agrigo\node_modules\tns-core-modules-widgets\platforms\android\widgets-release.aar
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to find Platform SDK with path: platforms;android-28
In my Android SDK, I tried to install API 28 but it kept on failing and failing. My current SDK looks like:
given API 21 is installed, I tried:
tns run android --compileSdk 21 --emulator
It first does show 28.0.0. then gives a lot of errors:
+ setting applicationId
+ applying user-defined configuration from D:\pyworks\agrigo7\mobileapp\agrigo\app\App_Resources\Android\app.gradle
**Using support library version 28.0.0**
+ adding nativescript runtime package dependency: nativescript-optimized-with-inspector
+ adding aar plugin dependency: D:\pyworks\agrigo7\mobileapp\agrigo\node_modules\tns-core-modules-widgets\platforms\android\widgets-release.aar
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Android resource linking failed
Output: error: resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found.
error: resource android:style/TextAppearance.Material.Widget.Button.Colored not found.

I think you are getting confused between the support library and SDK version. They are different and your support library's major version should always match your SDK's major version which means you can't use support library 28.x with SDK 21.x.
#Jenlooper had given a brief about this breaking change at the 5.0 launch, you must specify the right support library version in the gradle file (project.ext.supportVersion).
Besides, Google Play restricts all new app submissions to target SDK 26 (Android 8.0) so I would recommend you to try SDK 26 instead of 21 which you can't use to publish.

Related

Android-studio 3.5.1 Gradle ERROR: No value has been specified for property lottie-react-native

Upgraded android studio to 3.5.1. Took fresh checkout of project and gradle sync started failing. Searched everywhere but could not find any proper solution. In logs can see error at line 97 of lottie react native android gradle-maven-push.gradle
Have tried downgrading gradle version, android studio version as well but still same error.
Gradle task defined in gradle-maven-push.gradle
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath()
.join(File.pathSeparator))
}
Got it working by changing the code to
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath()
.join(File.pathSeparator)) + configurations.implementation
}
Reference: https://github.com/airbnb/lottie-android/blob/master/lottie/build.gradle
The difference is that of configuration.implementation between what is downloaded in lottie's react native module's build.gradle and and specified in github link.

How to fix "Could not find or load main class org.gradle.launcher.daemon.bootstrap.GradleDaemon" in flutter?

I have set up my new PC and I'am already having some problems with Flutter. It used to run fine on my older PC.
I've installed Android Studio, Android SDK, Flutter, VS Code with Dart and Flutter plugins, and after that created new flutter project. After connecting my phone to PC and hitting F5 I'm getting this error:
* Error running Gradle:
ProcessException: Process "D:\FlutterProjects\quotes\android\gradlew.bat" exited abnormally:
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/4.10.2/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------
Error: Could not find or load main class org.gradle.launcher.daemon.bootstrap.GradleDaemon
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Command: D:\FlutterProjects\quotes\android\gradlew.bat app:properties
Please review your Gradle project setup in the android/ folder.
Flutter doctor looks fine.
Here are my gradle-wrapper.properties:
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
And gradle.properties:
org.gradle.jvmargs=-Xmx1536M
org.gradle.daemon=true
org.gradle.parallel=true
And the last thing, build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Can anyone help me with that problem?
run
flutter clean
it will clean your current build folder and cache, then when you run your Flutter App, a new Build folder will be created.
in most cases it fix it.

InvokeDynamic not supported when building for Android

I'm running Gluon/charm version 3.0.0. I added a Java8-compiled library into my JavaFX project (created via the IntelliJ plugin) and on iOS it works and builds as expected, but when executing the gradle tasks android or androidInstall I get this error back:
[ant:java] Java Result: 1
:createMainDexList FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':createMainDexList'.
> Exception in thread "main" com.android.dx.cf.iface.ParseException: InvokeDynamic not supported
at com.android.dx.cf.cst.ConstantPoolParser.determineOffsets(ConstantPoolParser.java:226)
at com.android.dx.cf.cst.ConstantPoolParser.parse(ConstantPoolParser.java:132)
at com.android.dx.cf.cst.ConstantPoolParser.parseIfNecessary(ConstantPoolParser.java:124)
at com.android.dx.cf.cst.ConstantPoolParser.getPool(ConstantPoolParser.java:115)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:491)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToEndIfNecessary(DirectClassFile.java:397)
at com.android.dx.cf.direct.DirectClassFile.getAttributes(DirectClassFile.java:311)
at com.android.multidex.MainDexListBuilder.hasRuntimeVisibleAnnotation(MainDexListBuilder.java:191)
at com.android.multidex.MainDexListBuilder.keepAnnotated(MainDexListBuilder.java:167)
at com.android.multidex.MainDexListBuilder.<init>(MainDexListBuilder.java:121)
at com.android.multidex.MainDexListBuilder.main(MainDexListBuilder.java:91)
at com.android.multidex.ClassReferenceListBuilder.main(ClassReferenceListBuilder.java:58)
...while preparsing cst 0002 at offset 0000000f
...while parsing de/<removed>/traffic_light/library/Test.class
What I find a bit weird is that I don't even have a Test class for traffic_light, not even in the library. Searching for the error I found that it probably needs Java 8 to invokeDynamic/Support Lambdas, but for example Gluon's Presenter itself uses Lambdas.
Also, googling I find this hit about the same issue but sadly Gluon removed their forum and the page isn't cached anywhere.
Typically this error happens when you add some third party dependencies to the project that use lambda expressions, since currently the retrolambda plugin is applied to the source code of your project only.
You can try:
Remove that dependency and add its source code instead.
Apply retrolambda to the original dependency, and then add it to your project.
Or use the most recent jfxmobile plugin: the 1.0.10-SNAPSHOT will apply retrolambda to both the source code and the third party dependencies (even if no source code is provided).
For the last option, just change the jfxmobile plugin version on top of your build.gradle file:
buildscript {
repositories {
jcenter()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.10-SNAPSHOT'
}
}

Android Studio Execution failed for task ':app:dexDebug'

I'm trying to start my first Android Studio app and coming across the same error over and over when I try to run or debug. I'm building a music app using the Spotify API and have imported the zipped jar files in the correct directory (under libs in my app).
What seems to be the problem is that maybe my SDK folder is in another drive? I don't think so, but it was the only thing I can think it would be. I even moved over my Android Studio folder and tried running it from the same D: drive but didn't make any difference.
I also have all the appropriate SDKs installed incl. SDK Tools, Platform-tools, SDK Build-tools 19.1, 20, API 19, 20, Android Support Repository, Library, Google Play serivces, Repository, USB Driver, and Intel Emulator.
This is the error I am getting:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
D:\adt-bundle-windows-x86_64-20140702(2)\adt-bundle-windows-x86_64-20140702\sdk\build-tools\19.1.0\dx.bat --dex --output C:\Users\Jesse\AndroidStudioProjects\SubRosa\app\build\intermediates\dex\debug C:\Users\Jesse\AndroidStudioProjects\SubRosa\app\build\intermediates\classes\debug C:\Users\Jesse\AndroidStudioProjects\SubRosa\app\build\intermediates\dependency-cache\debug C:\Users\Jesse\AndroidStudioProjects\SubRosa\app\build\intermediates\exploded-aar\com.spotify.sdk\spotifysdk\1.0.0-beta5\libs\jnihelpers-1.0.jar D:\adt-bundle-windows-x86_64-20140702(2)\adt-bundle-windows-x86_64-20140702\sdk\extras\android\m2repository\com\android\support\support-v4\19.0.1\support-v4-19.0.1.jar C:\Users\Jesse\AndroidStudioProjects\SubRosa\app\build\intermediates\exploded-aar\com.spotify.sdk\spotifysdk\1.0.0-beta5\classes.jar C:\Users\Jesse\AndroidStudioProjects\SubRosa\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\19.0.1\classes.jar
Error Code:
1
Output:
'D:\adt-bundle-windows-x86_64-20140702' is not recognized as an internal or external command,
operable program or batch file.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Here is some my code and gradle builds/props:
local.properties
sdk.dir=D\:\\adt-bundle-windows-x86_64-20140702(2)\\adt-bundle-windows-x86_64-20140702\\sdk
build.gradle(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0' // Note: this version should match the latest build-tools version
// that you installed in the SDK manager
defaultConfig {
applicationId "com.jesse.spalding.subrosa"
minSdkVersion 14
targetSdkVersion 19
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
dexOptions {
preDexLibraries = false
}
}
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.spotify.sdk:spotifysdk:1.0.0-beta5#aar'
compile 'com.android.support:appcompat-v7:19.0.1'
}
If anyone has any idea what the deal is what this, please let me know. I need to start working on this for a final project and just can't figure this technical thing out for some reason.
The problem seems to be that your SDK is in a path that has a parenthesis in it (D:\adt-bundle-windows-x86_64-20140702(2)\adt-bundle-windows-x86_64-20140702\sdk), which is causing problems in one of the phases of the build process. Move your SDK to a path with a simpler name and update its location in Android Studio (Project Structure > SDK Location) and you should be good to go.

Gradle error on Android Studio startup

Every time I start Android Studio I get the following error:
Gradle 'VertretungsplanProject' project refresh failed: Could not
fetch model of type 'IdeaProject' using Gradle distribution
'http://services.gradle.org/distributions/gradle-1.6-bin.zip'. A
problem occurred configuring project ':Vertretungsplan'. A problem
occurred configuring project ':Vertretungsplan'. Failed to notify
project evaluation listener. A problem occurred configuring project
':libraries:actionbarsherlock'. Failed to notify project evaluation
listener. Could not normalize path for file
'P:\Projekte\VertretungsplanProject\libraries\actionbarsherlock:Vertretungsplan\libs\android-support-v4.jar'.
The syntax for the filename, directoryname or the volume label is
wrong
My project looks like this:
Gradle settings:
build.gradle of :Vertretungsplan:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/commons-io-2.4.jar')
compile project(':libraries:actionbarsherlock')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 16
}
}
build.gradle of :VertretungsplanProject is empty.
build.gradle of :actionbarsherlock:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
dependencies {
compile files(':Vertretungsplan/libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
When I want to compile now this error appears:
Deprecated make implementation
Old implementation of "Make" feature is enabled for this project.
It has been deprecated and will be removed soon.
Please enable newer 'external build' feature in Settings | Compiler.
After changing this setting to Use external build everything is working fine.
But this appears every time I start Android Studio and this is really annoying.
UPDATE
I deleted the android-support-v4.jar from the libs folder and simply wrote compile 'com.android.support:support-v4:18.0.0' to the build.gradle of ActionbarSherlock. Then the android-support-v4.jar is used from the installed SDK.
EDIT
Go to File > Settings > "Build,Execution,Deployment"> Compiler
Click compiler directly.
Check the option: Use external build > Apply > OK.
It worked for me !! :)
You seem to have more than one issue. Problems loading gradle on startup and problems resolving the dependency path name in your environment.
I recently found a fix for the "Failed to import Gradle project" issue, which could be linked to your dependency issue.
At least if you fix one, you know your issue could specifically be the dependency path resolution rather than a gradle/android studio issue...
Check out the troubleshooting section here:
http://developer.android.com/sdk/installing/studio.html#Troubleshooting
The basic steps are:
1. Close android studio
2. Open the SDK manager
(run android binary/executable which should be in /tools)
3. Scroll down the list and expand extras
4. Tick the "Android Support Repository"
5. Click Install Packages.. etc etc...
You need to download this as Android Studio 0.2.x needs a new maven repository used by the new build system for the support library, instead of using support library jar's.
Let us know if anything changes after trying this fix.
In the error message, the path appears: 'P:\Projekte\VertretungsplanProject\libraries\actionbarsherlock\:Vertretungsplan\libs\android-support-v4.jar'
It looks like you're on Windows. The semicolon before Vertretungsplan is not a legal filesystem character. This appears in your script as
compile files(':Vertretungsplan/libs/android-support-v4.jar')
Try changing this to
compile files('Vertretungsplan/libs/android-support-v4.jar')

Resources