Generating a LibGdx project into android studio version 1.0? - java

I followed the instructions on here http://www.programmingmoney.com/setup-libgdx-android-studio/ for installing and using LibGdx on Android Studio 1.0(official release). I am on step 4, the actual generation step. When I tried import project, I got this exception
Gradle version 2.1 is required. Current version is 2.2.1. If using the gradle wrapper, try editing the distributionUrl in C:\Users\chris\AndroidStudioProjects\SetUpGame\gradle\wrapper\gradle-wrapper.properties to gradle-2.1-all.zip.
This was a similar error to what this person got in this thread - Upgrading project to Android Studio 1.0 (Gradle problems).
When i went to view gradle-wrapper.properties with notepad ++, this was what i saw
distributionUrl=http\://services.gradle.org/distributions/gradle-2.1-all.zip
which meant that this didn't have to be changed. (the answer that was given in the other thread)
Does anyone know what the issue is? Is Android studio version 1.0 too new for Libgdx? I m not that familiar with Gradle.

Look through all your build.gradle files and update the version of the Android Gradle plugin that's specified. If you see buildscript --> dependencies blocks, update them to version 1.0.0 of the Android Gradle plugin like so:
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
I think there may be a bug where if you have the wrong version of the plugin, it gives you a bogus error about having the wrong version of Gradle, and you get ping-ponging error messages when you change it back and forth because it's not fixing the root cause of the error, which is this different version number.

Related

Your project may be using a third-party plugin which is not compatible with the other plugins in the project

The problem might be similar or looks duplicated but it doesn't. I Tried every possible solution on Stackoverflow and YouTube but I couldn't solve the issue with my project. I have already released the app to Google Play Store as well. but Now facing this problem.
Error:
Your project may be using a third-party plugin that is not compatible with the other
plugins in the project or the version of Gradle requested by the project
The things I have tried:
I removed all the Gradle files and downloaded them again.
I compare all the libs and repositories with my other projects which are working with no issue. (but have not solved this project's problem).
I had recently added a module to add Native ads on this app and removed that too. (Not had any positive impact).
Several times I restarted the project and rebuilt the project. (result: nothing) I tried anything I could. the problem still exists.
I was facing the same issue. I just changed the version of these two lines.
Replace these two lines with yours and sync the project.
Build.gradle (Project)
classpath 'com.android.tools.build:gradle:7.0.4'
Gradle.wrapper.properties
distributionUrl=https://services.gradle.org/distributions/gradle-7.5.1-bin.zip
I am using:
Android Studio Dolphin | 2021.3.1 Patch 1
Build #AI-213.7172.25.2113.9123335, built on September 30, 2022

Localazy: Localazy Gradle plugin requires Android Gradle plugin 3.5.0 and newer

I am trying to use https://localazy.com/p/locakalazy/integration/android for android language localization.
But while adding this in app module ->
apply plugin: 'com.localazy.gradle'
localazy {
readKey "########"
writeKey "########"
}
I am getting this error ->
Build file 'C:\Users\91863\AndroidStudioProjects\android-localization\app\build.gradle' line: 48
An exception occurred applying plugin request [id: 'com.localazy.gradle']
Failed to apply plugin 'com.localazy.gradle'.
Localazy: Localazy Gradle plugin requires Android Gradle plugin 3.5.0 and newer.
But I do have the newer plugin version
I'm the author of the Localazy Gradle plugin and I will do my best to help you resolve the issue.
It seems that the version cannot be obtained correctly from the Android Gradle plugin and thus Localazy Gradle plugin fails.
Would you be so kind to contact us through the online chat on our website? I would need more information about your situation to simulate and resolve it.
Once we fix it for you (and possibly all other users as well), I will publish the solution here.
EDIT: The detection mechanism was fixed in version 1.5.4.

Could not resolve all files for configuration ':app:androidApis'

CONFIGURE SUCCESSFUL in 1s
Calling mockable JAR artifact transform to create file: C:\Users...gradle\caches\transforms-1\files-1.1\android.jar\637e2bccbff6bd0f7a7583f7e9d4551b\android.jar with input C:\Users...\AppData\Local\Android\Sdk\platforms\android-28\android.jar
Gradle sync failed: Could not resolve all files for configuration ':app:androidApis'.
Failed to transform file 'android.jar' to match attributes {artifactType=android-mockable-jar, returnDefaultValues=false} using transform MockableJarTransform
Cannot create mockable android.jar
zip file is empty
I am new to android studio. I have tried all the answers I could get none worked.
I changed my gradle plugin to 3.1.1 and lower is still the same thing.
I have clean build and invalidate cache/reset.
Do I have to install a lower android studio. Why is this happening for a new project?
Andriod studio 3.2.1
#Openwell thanks a lot. you save my day!
I found the source of the problem. I noticed that the andriod.jar file in C:\Users**\AppData\Local\Android\Sdk\platforms\android-28 was missing, the file was 0kb. which shouldn't be so. So I reinstalled the Android SDK platform and sources by uninstalling it from SDK Manager and installed it back. then the problem was solved.
I just changed the compiled version to API level to which I have downloaded in the SDK Manager. For me in File=>Project Structure, the compiled version is set to 29 which I haven't downloaded SDK. So I changed it to 28 which I have downloaded.Then it worked.
After upgrading AndroidStudio version to 4.1, also upgraded Android Gradle plugin to 4.1.0.
But in Project root folder build.gradle file, In dependencies, it has this below gradle classpath for com.google.gms:google-services version as 4.3.0. Caused the issue.
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.google.gms:google-services:4.3.0'
}
after upgrading com.google.gms:google-services to latest version, and Sync project.
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.google.gms:google-services:4.3.4'
}
Solved the issue.

Error:(2, 0) Plugin with id 'jetty' not found

Yesterday I upgraded Android Studio to version 3.0, but I'm working with LibGdx and after the upgrade I cannot build my project.
When I'm try to build, it gives me an error:
Error:(2, 0) Plugin with id 'jetty' not found
How should I fix this?
Currently html module using deprecated jetty plugin which is removed in Gradle 4.1 version.
Android Studio 3.0 using Gradle-4.1 and android-gradle-plugin:3.0.0
Gradle 4.1 is not supported yet in LibGDX, there is an issue for the same, which is now upgraded for Gradle 4.6
If you still want to use Android Studio 3.0
Downgrade Gradle to 3.3 from 4.1
Find gradle folder inside your project, Open gradle-wrapper.properties and change distributionUrl for 3.3
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Downgrade Android-gradle-plugin to 2.3.3 from 3.0.0
Open root build.gradle file and find artifact and change version
classpath 'com.android.tools.build:gradle:2.3.3'
Comment/delete google() from repo list
--------------------------------------------------------------------------------
EDIT : Update LibGDX project to Gradle 4.6 - AS USER
Upgrade Gradle to 4.6 :
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
Find root build.gradle file of your project and add Google's Maven repo in project repositories list as well as in buildScript repo list
repositories {
//..
google()
jcenter() // Required for org.jetbrains.trove4j:trove4j library
}
Update Android Gradle Plugin :
classpath 'com.android.tools.build:gradle:3.1.3'
Known issues with the Android Gradle Plugin
Configuration on demand with Gradle 4.6 and above:
If you're using Android Gradle Plugin 3.0.x or 3.1.x with Gradle 4.6
and above, you should disable configuration on demand to avoid some
unpredictable build errors. (If you are using Android Gradle Plugin
3.2.0 or higher, you do not need to take any action to disable configuration on demand.)
Disable configuration on demand in your gradle.properties file as shown below:
org.gradle.configureondemand=false
To disable configuration on demand in the Android Studio settings, choose File > Settings (Android Studio > Preferences on Mac), select the Compiler category in the left pane, and clear the Configure on demand checkbox.
In Android Studio 3.2 Beta 1 and higher, the options for enabling configuration on demand have been removed.
Update Android buildToolsVersion to 27.0.3 and SdkVersion to 27
Remove instrumentTest.setRoot('tests') from sourceSets inside android build.gradle file
replace all compile with implementation inside root build.gradle file
New GWT Gradle Plugin added in html module, check latest build.gradle of html module.
Run your project with Run Configuration or On Terminal using gradle task.
If you're going to create new project use gdx-setup.jar of latest build.
Suggestion from Jetty Plugin team is to switch to gretty
Please check this
Error while replacing jetty plugin to gretty plugin gradle

Can't run imported gradle android project in Eclipse

First, im new in gradle so please bear with me.
I successfully build and imported this project with gradle & eclipse on ubuntu 13.10. This is what i did :
run gradle build in terminal (success)
add apply plugin: 'eclipse' in the build.gradle
run gradle eclipse in terminal (success)
import it as existing project on eclipse
The problem is, when i tried to run the project, eclipse read it as "normal" java program, not the android one. This is the SS :
The main project in my workspace is not in eclipse format.
And this is its properties :
Notice there's no android tab in it's properties. And i cant run it as android application.
Am i missing something? Please kindly help me.
Thanks for your help.
Usually to develop Android in Eclipse you need to install ADT into Eclipse or start with ADT-Bundle (Android IDE) from Google. (You have not as Preferences missing Android group)
However ADT does not have gradle support. And Android Studio is still not even yet beta (preview or alpha, bleeding edge, need to update with almost every build).
There is Nodeclipse/Enide Gradle for Eclipse
(marketplace), that lets launch gradle build even on general project.
For the latest build.gradle template for classic Android project check
gh.c/N/n-1/b/m/o.n.e.e.g/docs/android/build.gradle.
This lets create new Android project in Eclipse with ADT and use ADT tools for most of things,
but additionally have newer build with gradle
and execute defined gradle tasks
But for Android project with several modules (as in this case) you would need to DIY do it yourself:
try to configure Eclipse .classpath to correct values, as gradle eclipse task won't yet do it all for you.
Eclipse plugin in Gradle that you have used does not support Android projects - they are significantly different from regular Java projects. Some things can work but there will be a lot of things missing including Android nature for generated projects.
And the ADT plugin provided by Google does not support Gradle projects yet as the team focuses on Android Studio first. http://tools.android.com/tech-docs/new-build-system can give you some ideas about the current state.

Categories

Resources