2016-04-26 4 views
0

Ich versuche, die über Seitenbibliothek mitWie die über Seitenbibliothek in Android Studio setzen

Kompilierung auf 'com.github.medyo: android-about-Seite: 1.0.2'

Aber ich bin ein Laufzeitfehler bekomme ich gesetzt haben, wie es hier im github gegeben ist mein Java-Code

import android.os.Bundle; 
import android.support.v7.app.AppCompatActivity; 
import android.view.View; 
import mehdi.sakout.aboutpage.AboutPage; 
import mehdi.sakout.aboutpage.Element; 

public class MainActivity extends AppCompatActivity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    Element versionElement = new Element(); 
    versionElement.setTitle("Version 6.2"); 

    Element adsElement = new Element(); 
    adsElement.setTitle("Advertise with us"); 

    View aboutPage = new AboutPage(this) 
      .isRTL(false) 
      .setImage(R.drawable.wall) 
      .addItem(versionElement) 
      .addItem(adsElement) 
      .addGroup("Connect with us") 
      .addEmail("[email protected]") 
      .addFacebook("the.medy") 
      .addTwitter("medyo80") 
      .addYoutube("UCdPQtdWIsg7_pi4mrRu46vA") 
      .addPlayStore("com.ideashower.readitlater.pro") 
      .addInstagram("medyo80") 
      .addGitHub("medyo") 
      .create(); 

    setContentView(aboutPage); 
} 

} kann mir jemand sagen, welche Veränderungen werde ich in meinem Code tun, um die Support-Bibliothek festlegen Ich versuche eine Bibliothek vonzu importieren Ich habe die Gradel synchronisiert. Gradel Datei

apply plugin: 'com.android.application' 


buildscript { 
repositories { 
    jcenter() 
} 
} 
android { 
compileSdkVersion 23 
buildToolsVersion "23.0.1" 

defaultConfig { 
    applicationId "com.union.test7" 
    minSdkVersion 16 
    targetSdkVersion 23 
    versionCode 1 
    versionName "1.0" 
} 
    buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 

}

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 
testCompile 'junit:junit:4.12' 
compile 'com.android.support:appcompat-v7:23.3.0' 
compile 'com.android.support:design:23.3.0' 
compile 'com.github.medyo:android-about-page:1.0.2' 
} 

Ich bin in der Lage, das Programm zu kompilieren, aber es ist in meinem Emulator Fehler

E/AndroidRuntime: FATAL EXCEPTION: main 
              java.lang.RuntimeException: Unable to start activity ComponentInfo{com.union.test7/com.union.test7.MainActivity}: java.lang.NullPointerException 
               at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059) 
               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) 
              Caused by: java.lang.NullPointerException 
+0

Bitte geben Sie Ihre Gradle-Datei an. –

+0

Ich habe den Beitrag bearbeitet hoffe, es wird dir helfen –

+0

Überprüfen Sie meine Antwort unten. –

Antwort

2

In order to use this Library you need to use jcenter nicht aktiv.

As it defines Available on Jcenter, Maven and JitPack.

Ändern Sie also Ihre Build.Gradle wie folgt.

apply plugin: 'com.android.application' 

buildscript { 
    repositories { 
     jcenter() 
    } 
} 

Und hier ist der Code, den Sie verwenden müssen.

public class MainActivity extends AppCompatActivity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     Element versionElement = new Element(); 
     versionElement.setTitle("Version 6.2"); 

     Element adsElement = new Element(); 
     adsElement.setTitle("Advertise with us"); 

     View aboutPage = new AboutPage(this) 
       .isRTL(false) 
       .setImage(R.drawable.dummy_image) 
       .addItem(versionElement) 
       .addItem(adsElement) 
       .addGroup("Connect with us") 
       .addEmail("[email protected]") 
       .addFacebook("the.medy") 
       .addTwitter("medyo80") 
       .addYoutube("UCdPQtdWIsg7_pi4mrRu46vA") 
       .addPlayStore("com.ideashower.readitlater.pro") 
       .addInstagram("medyo80") 
       .addGitHub("medyo") 
       .create(); 

     setContentView(aboutPage); 
    } 
} 

Hinweis:setContentView(R.layout.activity_main) ist nicht erforderlich, in den Code zu schreiben, weil Bibliothek es automatisch generieren.

+0

all dies unter "android {}" –

+0

Nein nur unter "Plug-Ins: 'com.android.application'' wie ich in Antwort gegeben habe. –

+0

nicht funktioniert bro –

Verwandte Themen