正确的表单将库导入Android Studio

时间:2015-06-12 07:11:25

标签: android android-studio libgdx

好吧,我试着做http://swarmconnect.com/admin/docs/setup教程,但它是在eclipse中,所以我试着在Android Studio中做但我无法做到。 这就是我所拥有的,但我所做的一切都不起作用。我知道问题是我不知道我需要如何导入库(swarm proyect)。

如果我从游戏(项目)开始完成,你可以告诉我自己做错了什么或者从一开始就要做什么。

感谢您的帮助。

我有这样的项目。 http://postimg.org/image/l2xa95czt/

我在AndroidManifest.xml中有这个

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mygdx.game.android"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="22" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/GdxTheme" >
        <activity
            android:name="com.mygdx.game.android.AndroidLauncher"
            android:label="@string/app_name" 
            android:screenOrientation="landscape"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:configChanges="orientation|keyboardHidden"
            android:label="Swarm"
            android:name="com.swarmconnect.SwarmMainActivity"
            android:theme="@android:style/Theme.NoTitleBar"
            android:windowSoftInputMode="stateHidden"/>

        <service
            android:name="com.swarmconnect.NotificationService"
            android:process=":swarm"/>



    </application>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

    <!-- Required if using the Swarm Store features. Not required otherwise. -->
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
</manifest>

build.gragle

buildscript {
    repositories {
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
    }
}

allprojects {
    apply plugin: "eclipse"
    apply plugin: "idea"

    version = '1.0'
    ext {
        appName = 'juegoPONG'
        gdxVersion = '1.6.1'
        roboVMVersion = '1.2.0'
        box2DLightsVersion = '1.3'
        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"
        compile "com.badlogicgames.gdx:gdx-box2d-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"
        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-x86"
        compile fileTree(dir: '../libs', include: '*.jar')
        //compile project(":SwarmConnect")
    }
}

project(":core") {
    apply plugin: "java"


    dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
        compile fileTree(dir: '../libs', include: '*.jar')
    }
}




tasks.eclipse.doLast {
    delete ".project"
}

输出错误

06-12 06:50:09.619    6008-6008/com.mygdx.game.android D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x0031
06-12 06:50:09.623    6008-6008/com.mygdx.game.android I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x1b81 at 0x16 in Lcom/swarmconnect/UiConf;.a
06-12 06:50:09.635    6008-6008/com.mygdx.game.android I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x1b64 at 0x1d in Lcom/swarmconnect/UiConf;.a
06-12 06:50:09.647    6008-6008/com.mygdx.game.android I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x1b80 at 0x34 in Lcom/swarmconnect/UiConf;.a
06-12 06:50:09.647    6008-6008/com.mygdx.game.android I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x1b2c at 0x37 in Lcom/swarmconnect/UiConf;.a
06-12 06:50:09.647    6008-6008/com.mygdx.game.android I/System.out﹕ primero2
06-12 06:50:09.695    6008-6008/com.mygdx.game.android I/AndroidInput﹕ sensor listener setup
06-12 06:50:09.695    6008-6008/com.mygdx.game.android I/System.out﹕ primero11
06-12 06:50:09.699    6008-6008/com.mygdx.game.android I/Swarm﹕ Swarm Version v2
06-12 06:50:09.783    6008-6032/com.mygdx.game.android I/SwarmIOClient﹕ SwarmIO ClientID: c4e6dff3-e70b-4a7f-9988-121f3574fec5
06-12 06:50:09.823    6008-6010/com.mygdx.game.android D/dalvikvm﹕ GC_CONCURRENT freed 364K, 10% free 8059K/8903K, paused 17ms+29ms, total 63ms
06-12 06:50:09.831    6008-6008/com.mygdx.game.android D/dalvikvm﹕ WAIT_FOR_CONCURRENT_GC blocked 22ms
06-12 06:50:10.499    6008-6008/com.mygdx.game.android I/System.out﹕ primero10
06-12 06:50:10.735    6008-6008/com.mygdx.game.android I/AndroidInput﹕ sensor listener tear down
06-12 06:50:10.771    6008-6008/com.mygdx.game.android I/System.out﹕ primero3
06-12 06:50:10.851    6008-6008/com.mygdx.game.android W/dalvikvm﹕ VFY: unable to resolve static field 7038 (HoloTheme) in Lcom/swarmconnect/R$style;
06-12 06:50:10.895    6008-6008/com.mygdx.game.android D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x0003
06-12 06:50:10.971    6008-6008/com.mygdx.game.android D/AndroidRuntime﹕ Shutting down VM
06-12 06:50:10.991    6008-6008/com.mygdx.game.android W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa62d1288)
06-12 06:50:11.135    6008-6008/com.mygdx.game.android E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.NoClassDefFoundError: com.swarmconnect.R$style
            at com.swarmconnect.SwarmMainActivity.onCreate(Unknown Source)
            at android.app.Activity.performCreate(Activity.java:5008)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
            at android.app.ActivityThread.access$600(ActivityThread.java:130)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4745)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
            at dalvik.system.NativeStart.main(Native Method)
06-12 06:50:12.771    6008-6037/com.mygdx.game.android D/dalvikvm﹕ GC_FOR_ALLOC freed 385K, 10% free 8231K/9095K, paused 25ms, total 25ms
06-12 06:50:12.823    6008-6010/com.mygdx.game.android D/dalvikvm﹕ GC_CONCURRENT freed 14K, 10% free 8257K/9095K, paused 13ms+13ms, total 33ms
06-12 06:50:13.059    6008-6037/com.mygdx.game.android D/dalvikvm﹕ GC_FOR_ALLOC freed 436K, 10% free 8372K/9287K, paused 8ms, total 8ms
06-12 06:50:13.079    6008-6010/com.mygdx.game.android D/dalvikvm﹕ GC_CONCURRENT freed 60K, 10% free 8365K/9287K, paused 2ms+1ms, total 6ms

AndroidLauncher.java

import android.os.Bundle;

import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.mygdx.game.Main;
import com.swarmconnect.Swarm;
import com.swarmconnect.SwarmLeaderboard;

public class AndroidLauncher extends AndroidApplication {




    @Override
    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
        initialize(new Main(), config);
        System.out.println("primero1");

        Swarm.setActive(this);
        System.out.println("primero2");


    }

    public void onResume() {
        super.onResume();
        Swarm.setActive(this);
        System.out.println("primero11");
        Swarm.init(this, 17921, "0b123ca0df843572182306db3b1675aa");
        SwarmLeaderboard.submitScore(19655, 10);
        System.out.println("primero10");
    }

    public void onPause() {
        super.onPause();
        Swarm.setInactive(this);
        System.out.println("primero3");
    }




}

0 个答案:

没有答案