Building libgdx project
First time i got error re-download dependencies and sync project each time i build my project. Then i got the solution from this POST
I did change the following from as instructed from the post
file -> project structure -> project
i. gradle version from 3.3 to 2.14.1
ii. update android studio plugin to 2.2.3 (it was unset)
I did take the values from recent working android project
My build.gradle
buildscript {
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'org.robovm:robovm-gradle-plugin:1.14.0'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = 'FirstDemo'
gdxVersion = '1.6.4'
roboVMVersion = '1.14.0'
box2DLightsVersion = '1.4'
ashleyVersion = '1.4.0'
aiVersion = '1.5.0'
}
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
}
}
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
}
}
project(":ios") {
apply plugin: "java"
apply plugin: "robovm"
dependencies {
compile project(":core")
compile "org.robovm:robovm-rt:$roboVMVersion"
compile "org.robovm:robovm-cocoatouch:$roboVMVersion"
compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
}
}
project(":html") {
apply plugin: "gwt"
apply plugin: "war"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
}
}
tasks.eclipse.doLast {
delete ".project"
}
Now i am getting error "Plugin with id 'gwt' not found". Can someone please help!
add this dependency into your buildscript tag of your root build.gradle file
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
After addition your buildscript looks like this
buildscript {
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
jcenter()
}
dependencies {
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'org.robovm:robovm-gradle-plugin:1.14.0'
}
}
Related
this is my build.gradle
this is what happens when i attempt to run the built jar.
plugins {
id 'java'
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
implementation "net.dv8tion:JDA:5.0.0-alpha.6"
implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.1.2'
implementation"io.github.bonigarcia:webdrivermanager:5.1.0"
}
test {
useJUnitPlatform()
}
jar {
manifest {
attributes 'Main-Class': 'bullshitPackage.main'
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}
You could use the shadowjar plugin to include all dependencies in your jar.
To use it in your build.gradle file, try:
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.github.jengelman.gradle.plugins:shadow:7.0.0"
}
}
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '7.0.0'
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
implementation "net.dv8tion:JDA:5.0.0-alpha.6"
implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.1.2'
implementation"io.github.bonigarcia:webdrivermanager:5.1.0"
}
test {
useJUnitPlatform()
}
jar {
manifest {
attributes 'Main-Class': 'bullshitPackage.main'
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}
Then from your console, navigate to your project's root folder that contains the file gradlew, then run gradlew shadowjar to build the jar into the ./build/libs folder.
I followed google documentation to integrate my app to Google Analytics. But when adding on Module: app build.gradle
apply plugin: 'com.google.gms.google-services'
and building my app, I encountered this error:
Gradle sync failed: For input string: " 12"
My project build.gradle is:
plugins {
id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.8.1'
}
apply plugin: 'com.android.application'
apply plugin: 'io.objectbox'
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'io.fabric'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId 'xxx.xxxx.xxxxx'
minSdkVersion 19
targetSdkVersion 25
versionCode 74
versionName "1.0.5"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
manifestPlaceholders = [onesignal_app_id : "xxxxx-xxxxxx-xxx",
onesignal_google_project_number: "REMOTE"]
javaCompileOptions {
annotationProcessorOptions {
arguments = ['objectbox.debug': 'true']
}
}
}
dataBinding {
enabled = true
}
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:27.1.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-core:15.0.2'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
implementation 'com.facebook.android:facebook-login:[4,5)'
compile 'com.facebook.android:facebook-share:[4,5)'
compile 'com.android.support:appcompat-v7:27.1.1'
compile 'com.android.support:design:27.1.1'
implementation 'com.orhanobut:logger:2.2.0'
compile 'joda-time:joda-time:2.9.9'
compile('com.afollestad:bridge:5.1.2') {
exclude group: 'org.json', module: 'json'
}
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
compile 'jp.wasabeef:blurry:2.1.1'
compile 'com.makeramen:roundedimageview:2.3.0'
compile('com.redmadrobot:inputmask:2.3.0') {
exclude group: 'org.jetbrains', module: 'annotations'
}
compile 'se.emilsjolander:stickylistheaders:2.7.0'
compile 'com.daimajia.easing:library:2.0#aar'
compile 'com.daimajia.androidanimations:library:2.3#aar'
compile 'com.github.javadev:underscore:1.29'
compile 'com.onesignal:OneSignal:[3.7.1, 3.99.99]'
compile 'com.mixpanel.android:mixpanel-android:5.+'
compile 'com.github.thomper:sweet-alert-dialog:v1.4.0'
compile 'com.github.faranjit:currency-edittext:1.0.1'
compile 'org.apache.commons:commons-lang3:3.7'
compile 'com.google.guava:guava:24.1-android'
compile('com.crashlytics.sdk.android:crashlytics:2.8.0#aar') {
transitive = true
}
compile('com.github.worker8:tourguide:1.0.19-SNAPSHOT#aar') {
transitive = true
}
}
apply plugin: 'com.google.gms.google-services'
and app build.gradle is:
buildscript {
ext.objectboxVersion = '1.5.0'
repositories {
jcenter()
google()
mavenCentral()
maven { url "http://objectbox.net/beta-repo/" }
maven { url 'https://maven.google.com' }
maven { url 'https://jitpack.io' }
maven { url "https://raw.githubusercontent.com/smilefam/SendBird-SDK-Android/master/" }
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.google.gms:google-services:3.3.1'
}
}
allprojects {
repositories {
jcenter()
google()
mavenCentral()
maven { url "http://objectbox.net/beta-repo/" }
maven { url 'https://maven.google.com' }
maven { url 'https://jitpack.io' }
maven { url "https://raw.githubusercontent.com/smilefam/SendBird-SDK-Android/master/" }
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
if I remove apply
plugin: 'com.google.gms.google-services'
, the build normally works. But Firebase does not start correctly.
Reduce the version number of Google services. I had similar gradle sync error when using
com.google.gms:google-services:3.3.0
so I changed to
com.google.gms:google-services:3.2.1
and it worked.
Go to firebase and download your google-services.json and add it to your top level of your application.
So I am adding a mysql dependency to my build.gradle, and it syncs perfect, but the problem is that I cant use the dependency code.
for instance, I added mysql.jar as a dependency, and it loaded, but trying to import com.mysql.jdbc.driver wont work.
Notice that Im using libgdx library
My build.gradle:
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
}
dependencies {
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.0'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = "Baladiya"
gdxVersion = '1.9.6'
roboVMVersion = '2.3.0'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
compile files("libs/mysql.jar")
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
compile files("libs/mysql.jar")
}
}
project(":ios") {
apply plugin: "java"
apply plugin: "robovm"
dependencies {
compile project(":core")
compile "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
compile "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"
compile files("libs/mysql.jar")
}
}
project(":html") {
apply plugin: "gwt"
apply plugin: "war"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-box2d-gwt:$gdxVersion:sources"
compile files("libs/mysql.jar")
}
}
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
compile files("libs/mysql.jar")
}
}
tasks.eclipse.doLast {
delete ".project"
}
My import error:
Why do you need mysql.jar in the first place? Judging by what you showed us, you need just a driver - simply import a driver from jcenter or maven central for example:
compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.6'
into the core.
I am not quite sure about how many projects have libs/mysql.jar, but if you include compile files("libs/mysql.jar") dependency under each project, you need the jar under the corresponding project like this:
desktop/
|- src/
|- libs/mysql.jar
android/
|- src/
|- libs/mysql.jar
ios/
|- src/
|- libs/mysql.jar
html/
|- src/
|- libs/mysql.jar
core/
|- src/
|- libs/mysql.jar
Since you have already require desktop, android, ios, html projects depending on core,
so the dependency of compile files("libs/mysql.jar") is actually redundant,
you only need it to be included in core/.
Let me know if this works.
I'm having this very frustrating issue with my build.gradle file. It started when I decided to add new library to my project: "Deter-master" lib.
This is the error message:
Gradle sync failed: Could not find method compile() for arguments
[com.android.support:appcompat-v7:25.0.0] on
DefaultExternalModuleDependency{group='com.android.support',
name='support-v13', version='25.0.0', configuration='default'} of type
org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency.
Consult IDE log for more details (Help | Show Log)
Below you can see all gradle files:
apply plugin: 'com.android.application'
ext {
libraries = [
support : "25.0.0",
location: "9.8.0"
]
}
def config = project.ext.libraries
repositories {
mavenCentral()
mavenLocal()
flatDir {
dirs 'libs'
}
maven { url 'https://maven.fabric.io/public' }
}
repositories {
maven {
url 'https://dl.bintray.com/blipinsk/maven/'
}
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.airnauts.kaktus"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
signingConfigs {
debug {
storeFile file("../social_keystore.jks")
storePassword "social"
keyAlias "social"
keyPassword "social"
}
release {
storeFile file("../social_keystore.jks")
storePassword "social"
keyAlias "social"
keyPassword "social"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android {
packagingOptions {
exclude 'LICENSE.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile(name: 'toolkit', ext: 'aar')
compile "com.android.support:support-v13:${config.support}" compile "com.android.support:appcompat-v7:${config.support}" compile "com.android.support:support-v4:${config.support}" compile "com.android.support:recyclerview-v7:${config.support}" compile "com.android.support:design:${config.support}" compile "com.android.support:cardview-v7:${config.support}" compile "com.android.support:percent:${config.support}" compile "com.google.android.gms:play-services-location:${config.location}" compile "com.google.android.gms:play-services-maps:${config.location}"
//blipinsk
compile 'com.firebaseui:firebase-ui-auth:0.6.2'
compile 'com.bartoszlipinski:viewpropertyobjectanimator:1.2.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton:butterknife:7.0.0'
compile 'com.makeramen:roundedimageview:2.2.0'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'me.kaelaela:verticalviewpager:1.0.0#aar'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.firebase:firebase-auth:9.8.0'
compile 'com.firebaseui:firebase-ui:1.0.0'
compile 'com.android.support:support-v4:25.1.0'
compile 'com.karumi:dexter:4.1.0'
compile project('Libraries:Dexter-master')
}
apply plugin: 'com.google.gms.google-services'
Another part:
// 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.3.2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And the last one:
include ':app'
include ':app:Libraries:Dexter-master'
Try replacing:
compile "com.android.support:support-v13:${config.support}" compile "com.android.support:appcompat-v7:${config.support}" compile "com.android.support:support-v4:${config.support}" compile "com.android.support:recyclerview-v7:${config.support}" compile "com.android.support:design:${config.support}" compile "com.android.support:cardview-v7:${config.support}" compile "com.android.support:percent:${config.support}" compile "com.google.android.gms:play-services-location:${config.location}" compile "com.google.android.gms:play-services-maps:${config.location}"
with:
compile "com.android.support:support-v13:${config.support}"
compile "com.android.support:appcompat-v7:${config.support}"
compile "com.android.support:support-v4:${config.support}"
compile "com.android.support:recyclerview-v7:${config.support}"
compile "com.android.support:design:${config.support}"
compile "com.android.support:cardview-v7:${config.support}"
compile "com.android.support:percent:${config.support}"
compile "com.google.android.gms:play-services-location:${config.location}"
compile "com.google.android.gms:play-services-maps:${config.location}"
I'm using the Spring Boot gradle plugin to build an executable war. I have a FindResource.java class in src/main/resources to locate files:
FindResource.class.getResource(templateName).toURI()
When I execute gradle build I get an error, that the class FindResource cannot be resolved. Do I need to the the Spring Boot gradle plugin, that it should also use classes from the resources directory. How can I do so?
My build.gradle looks as follows:
buildscript {
ext {
springBootVersion = '1.2.5.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
apply plugin: 'io.spring.dependency-management'
jar {
baseName = 'abc'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.boot:spring-boot-starter-jersey")
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.apache.pdfbox:pdfbox:1.8.10")
compile('org.apache.poi:poi-ooxml:3.12')
compile('org.apache.poi:poi-scratchpad:3.12')
runtime("org.hsqldb:hsqldb")
testCompile("org.springframework.boot:spring-boot-starter-test")
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
As mentioned in the comment class files to load need to be in src/main/java/ and not in src/main/resources. This link may help give you more information on the convention of this structure.