okay.. I'm trying to create a splash screen for my mobile game. im using lib gdx library to create my game. i have a problem with importing the universal tween engine for my sprite splash. what should I do.
I've downloaded the universal tween engine and extracted it in the "libs" folder in the ios, android, core, and root of my project.. and i copied and paste these lines for each dependencies:
project(":core") {
fileTree(dir: 'D:/game/core/libs', include: 'tween-engine-api.jar')
compile fileTree(dir: 'D:/game/core/libs', include: 'tween-engine-api->sources.jar')
project(":desktop") {
compile fileTree(dir: 'D:/game/desktop/libs', include: 'tween-engine-api.jar')
compile fileTree(dir: 'D:/game/desktop/libs', include: 'tween-engine-api->sources.jar')
project(":ios") {
compile fileTree(dir: 'D:/game/ios/libs', include: 'tween-engine-api.jar')
compile fileTree(dir: 'D:/game/ios/libs', include: 'tween-engine-api->sources.jar')
project(":android") {
compile fileTree(dir: 'D:/game/android/libs', include: 'tween-engine-api.jar')
compile fileTree(dir: 'D:/game/android/libs', include: 'tween-engine-api->sources.jar')
the code in my Spite accessor class :
package com.game.test;
import aurelienribon.tweenengine.TweenAccessor;
public class SpriteAccessor implements TweenAccessor{
}
the error:
Error:(3, 33) java: package aurelienribon.tweenengine does not exist
Error:(5, 40) java: cannot find symbol symbol: class TweenAccessor
P.S.
Im following a video tutorial by dermetfan and I also put in th terminal these lines:
gradlew --refresh-dependencies
LibGdx uses gradle for dependency management.
You can inject dependency from repository.
add these lines in your core module of root build.gradle file.
repositories {
maven { url "https://jitpack.io" }
}
compile 'com.github.arcnor:universal-tween-engine:6.3.4'
compile 'com.github.arcnor:universal-tween-engine:6.3.4:sources'
Related
I want to make an expansion panel in my Android app but I tried many libraries and all of them can't sync in my Android Studio.
This is my build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.github.florent37:expansionpanel:1.1.1'
}
apply plugin: 'com.google.gms.google-services'
and this is what happens after sync:
Error:Failed to resolve: com.android.support:appcompat-v7:26.1.0
Install Repository and sync projectOpen FileShow in Project Structure dialog
You should change
compile 'com.android.support:appcompat-v7:25.1.1'
to
compile 'com.android.support:appcompat-v7:27.1.1'
which is the latest available version found here
https://developer.android.com/topic/libraries/support-library/packages
Add this to your project level gradle inside allprojects -> repositories
Add maven { url "https://maven.google.com" }
I'm using libGDX for my game which shares some code with another project. I put this code in a .jar library which I have added in the root build.gradle.
Everything works fine on desktop, but when I launch the game on Android it crashes with a ClassNotFound exception. It can't find a class of my the library.
Can anyone help me out? I have no idea what is causing the problem.
Edit: changes to build.gradle:
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile fileTree(dir: '../libs', include: '*.jar')
}
}
You need to add the same fileTree dependency directly in the android module because the Android Gradle plugin currently can't handle transitive flat file dependencies.
project(":core") {
...
compile fileTree(dir: '../libs', include: '*.jar')
...
}
// And also
project(":android") {
...
compile fileTree(dir: '../libs', include: '*.jar')
...
}
Source.
My goal is to distribute an .aar file that can be used by other developers in their projects. The problem I find is when i try integrate my .aar into other project, is i need specify all of the dependencies in their build.gradle file that I have already included in my .aar build.gradle.
My question it if possible only include my library as a dependency and somehow the libraries that my library depends on will get included in the other project.
For example, my library defines the following dependencies in its build.gradle file:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.altbeacon:android-beacon-library:2.3.5'
compile 'commons-codec:commons-codec:1.10'
}
I wrote a test app that uses my library and add like module in Android Studio interface
dependencies {
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:7.5.0'
compile project(':myLibrary')
}
However, this does not work. I get java.lang.VerifyErrors at runtime. What ends up working is to include this in the app's build.gradle file:
dependencies {
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:7.5.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.altbeacon:android-beacon-library:2.3.5'
compile 'commons-codec:commons-codec:1.10'
compile project(':myLibrary')
}
Why do I need to include dependencies in both the .aar and the final application? What am I not understanding about how dependencies work? Why isn't the final application able to grab the .aar's dependencies from maven or jCenter at build time?
I am a newbee in Gradle. I have a simple project structure (shown bellow) having a main android app module, one android module (myandroidlibrary), and one pure java module (myjavalibrary). They have simple dependencies, app -> myjavalibary, and myjavalibary -> myandroidlibrary (pls see fig. below). Gradle files snapshots are also given below.
However, while sync the gradle it produces following error:
D:\MyTestCodes\MyTestApplication\app\build.gradle
Warning:Module version MyTestApplication:myjavalibrary:unspecified depends on libraries but is a jar
Pls help me out! I have spent this whole day to sort it out with no result!
MyProject
- app
- myjavalibrary (pure java library)
- myandroidlibrary (android library)
Now the dependency is as follows:
"app" depends on -> "myjavalibrary"
"myjavalibrary" depends on -> "myandroidlibrary"
Gradle files for each of the modules are as follows:
build.gradle for app:
apply plugin: 'com.android.application'
android {
// ommitting other detail
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile project(':myjavalibrary')
}
build.gradle for myjavalibrary:
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':myandroidlibrary')
}
build.gradle for myandroidlibrary:
apply plugin: 'com.android.application'
android {
//ommiting other detail.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
}
settings.gradle:
include ':app', ':myjavalibrary', ':myandroidlibrary'
Now while I sync the gradle files it shows the following error:
D:\MyTestCodes\MyTestApplication\app\build.gradle
Warning:Module version MyTestApplication:myjavalibrary:unspecified depends on libraries but is a jar
Warning is caused by pure-jave myjavalibrary module having a dependency on the myandroidlibrary one, which is an Android library.
Gradle warns you that a pure-java module doesn't know anything about Android specific stuff of myandroidlibrary (like Android resources, assets etc.). By having this dependency (pure-java to android library one) you might lose some stuff you expect to have.
A much cleaner dependency direction would be the one from a android library to a pure-java library. In this case Gradle won't give you any warnings.
If you want to create an Android app project from java code, use apply plugin: 'com.android.application'.
If you want to create a library project from java code, use apply plugin: 'com.android.library'.
If you want to use pre-built jar files, do not create any project for them. Just add them into the projects, into the libs folder, which depend on them. The compile fileTree(dir: 'libs', include: ['*.jar']) in the dependencies would take care of them.
I created a new project in Android Studio 1.1 and I built successfully. After that, I added a jar libraries and updated build.gradle file
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile files('libs/commons-logging-1.1.1.jar')
compile files('libs/google-api-client-1.18.0-rc.jar')
compile files('libs/google-api-client-android-1.18.0-rc.jar')
compile files('libs/google-api-client-appengine-1.18.0-rc.jar')
compile files('libs/google-api-client-gson-1.18.0-rc.jar')
compile files('libs/google-api-client-jackson2-1.18.0-rc.jar')
}
Now, I am getting error "Local path doesn't exist."
I search other questions about this problem but I can't solve it. Help me please!
If you added jar libraries, your Gradle file should have updated itself correctly. Local path doesn't exist means that one of the files you want to compile is not in the path you have specified.
If you used
compile fileTree(dir: 'libs', include: ['*.jar'])
Then no need to add each .jar file one by one ,it means you have to remvoe following form your build.gradle.
compile files('libs/commons-logging-1.1.1.jar')
compile files('libs/google-api-client-1.18.0-rc.jar')
compile files('libs/google-api-client-android-1.18.0-rc.jar')
compile files('libs/google-api-client-appengine-1.18.0-rc.jar')
compile files('libs/google-api-client-gson-1.18.0-rc.jar')
compile files('libs/google-api-client-jackson2-1.18.0-rc.jar')