android - Integrate Fabric with Libgdx -
i trying integrate fabric sdk libgdx application android.
the android studio plugin provided fabric.io not work gradle build files (generated libgdx tool). plugin not touch them.
so tried edit them manually. build.gradle
file:
buildscript { repositories { mavencentral() maven { url 'https://maven.fabric.io/public' } } dependencies { classpath 'com.android.tools.build:gradle:1.1.+' classpath 'io.fabric.tools:gradle:1.+' } } allprojects { apply plugin: "eclipse" apply plugin: "idea" version = '1.0' ext { appname = 'app' gdxversion = '1.5.4' robovmversion = '1.0.0-beta-04' box2dlightsversion = '1.3' ashleyversion = '1.3.1' 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" compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxversion:natives-desktop" } } project(":android") { apply plugin: "android" apply plugin: 'io.fabric' 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" compile "com.badlogicgames.gdx:gdx-freetype:$gdxversion" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxversion:natives-armeabi" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxversion:natives-armeabi-v7a" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxversion:natives-x86" } repositories { mavencentral() maven { url 'https://maven.fabric.io/public' } } } project(":core") { apply plugin: "java" dependencies { compile "com.badlogicgames.gdx:gdx:$gdxversion" compile "com.badlogicgames.gdx:gdx-freetype:$gdxversion" } } tasks.eclipse.dolast { delete ".project" }
i have not touched android/build.gradle
file.
android { buildtoolsversion "22.0.1" compilesdkversion 22 sourcesets { main { manifest.srcfile 'androidmanifest.xml' java.srcdirs = ['src'] aidl.srcdirs = ['src'] renderscript.srcdirs = ['src'] res.srcdirs = ['res'] assets.srcdirs = ['assets'] } instrumenttest.setroot('tests') } } // needed add jni shared libraries apk when compiling on cli tasks.withtype(com.android.build.gradle.tasks.packageapplication) { pkgtask -> pkgtask.jnifolders = new hashset<file>() pkgtask.jnifolders.add(new file(projectdir, 'libs')) } // called every time gradle gets executed, takes native dependencies of // natives configuration, , extracts them proper libs/ folders // packed apk. task copyandroidnatives() { file("libs/armeabi/").mkdirs(); file("libs/armeabi-v7a/").mkdirs(); file("libs/x86/").mkdirs(); configurations.natives.files.each { jar -> def outputdir = null if (jar.name.endswith("natives-armeabi-v7a.jar")) outputdir = file("libs/armeabi-v7a") if (jar.name.endswith("natives-armeabi.jar")) outputdir = file("libs/armeabi") if (jar.name.endswith("natives-x86.jar")) outputdir = file("libs/x86") if (outputdir != null) { copy { ziptree(jar) outputdir include "*.so" } } } } task run(type: exec) { def path def localproperties = project.file("../local.properties") if (localproperties.exists()) { properties properties = new properties() localproperties.withinputstream { instr -> properties.load(instr) } def sdkdir = properties.getproperty('sdk.dir') if (sdkdir) { path = sdkdir } else { path = "$system.env.android_home" } } else { path = "$system.env.android_home" } def adb = path + "/platform-tools/adb" commandline "$adb", 'shell', 'am', 'start', '-n', 'net.snuzzle.android/net.snuzzle.android.androidlauncher' } // sets android eclipse project, using old ant based build. eclipse { // need specify java source sets explicitely, springsource gradle eclipse plugin // ignores nodes added in classpath.file.withxml sourcesets { main { java.srcdirs "src", 'gen' } } jdt { sourcecompatibility = 1.6 targetcompatibility = 1.6 } classpath { plusconfigurations += [project.configurations.compile] containers 'com.android.ide.eclipse.adt.android_framework', 'com.android.ide.eclipse.adt.libraries' } project { name = appname + "-android" natures 'com.android.ide.eclipse.adt.androidnature' buildcommands.clear(); buildcommand "com.android.ide.eclipse.adt.resourcemanagerbuilder" buildcommand "com.android.ide.eclipse.adt.precompilerbuilder" buildcommand "org.eclipse.jdt.core.javabuilder" buildcommand "com.android.ide.eclipse.adt.apkbuilder" } } // sets android idea project, using old ant based build. idea { module { sourcedirs += file("src"); scopes = [compile: [plus: [project.configurations.compile]]] iml { withxml { def node = it.asnode() def builder = nodebuilder.newinstance(); builder.current = node; builder.component(name: "facetmanager") { facet(type: "android", name: "android") { configuration { option(name: "update_property_files", value: "true") } } } } } } } dependencies { compile 'com.android.support:support-v4:22.1.1' compile 'com.android.support:appcompat-v7:22.1.1' compile 'com.melnykov:floatingactionbutton:1.2.0' }
the sdk not in classpath.
i'm using way add fabric (crashlytics) libgdx projects.
this build.gradle
.
buildscript { repositories { mavencentral() maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } maven { url 'https://maven.fabric.io/public' } } dependencies { classpath 'com.android.tools.build:gradle:1.2.3' ///... classpath 'io.fabric.tools:gradle:1.+' } } ///... project(":android") { apply plugin: 'com.android.application' apply plugin: 'io.fabric' repositories { jcenter() maven { url 'https://maven.fabric.io/public' } } ///.... dependencies { //... compile('com.crashlytics.sdk.android:crashlytics:2.2.2@aar') { transitive = true; } //...
i think difference gradle config adding crashlytics dependency.
now add android.permission.internet
permission in manifest, in oncreate
method of androidlauncher
add line
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); fabric.with(this, new crashlytics()); ///...
don't forget create fabric.properties
file in android module , add these lines it:
apisecret= your_api_secret_from_panel apikey=your_api_key_from_panel
now click on (fabric plugin android studio) , sign in click on install crashlytics (or other services) , after next buttons see dialog tells run application activating fabric.
now see game in fabric panel.
Comments
Post a Comment