lawang code

lawang Code


Tanyakan kode disini

Error Aplikasi google maps Android

ditanyakan oleh Indra 5 tahun yang lalu

Selamat pagi lawang code..saya mau tanyabarangkali ada solusi yg bisa menyelesasikan masalah pemrograman saya. saya membuat aplikasi android dimana memanfaatkan google maps api v2. nah setelah saya melakukan coding dengan tuntunan berbagai sumber ternyata muncul error seperti ini :

    11-11 21:45:38.102: E/dalvikvm(881): Could not find class 'com.google.android.gms.maps.SupportMapFragment', referenced from method com.example.pis.Peta.setupMap
11-11 21:45:38.102: W/dalvikvm(881): VFY: unable to resolve check-cast 724 (Lcom/google/android/gms/maps/SupportMapFragment;) in Lcom/example/pis/Peta;
11-11 21:45:38.122: D/dalvikvm(881): VFY: replacing opcode 0x1f at 0x000c
11-11 21:45:38.232: D/dalvikvm(881): DexOpt: unable to opt direct call 0x131f at 0x1a in Lcom/example/pis/Peta;.setupMap
11-11 21:45:38.282: D/dalvikvm(881): DexOpt: unable to opt direct call 0x1320 at 0x1f in Lcom/example/pis/Peta;.setupMap
11-11 21:45:39.132: D/AndroidRuntime(881): Shutting down VM
11-11 21:45:39.162: W/dalvikvm(881): threadid=1: thread exiting with uncaught exception (group=0x414c4700)
11-11 21:45:39.523: E/AndroidRuntime(881): FATAL EXCEPTION: main
11-11 21:45:39.523: E/AndroidRuntime(881): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.pis/com.example.pis.Peta}: android.view.InflateException: Binary XML file line #5: Error inflating class fragment
11-11 21:45:39.523: E/AndroidRuntime(881):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
11-11 21:45:39.523: E/AndroidRuntime(881):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
11-11 21:45:39.523: E/AndroidRuntime(881):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
11-11 21:45:39.523: E/AndroidRuntime(881):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
11-11 21:45:39.523: E/AndroidRuntime(881):  at android.os.Handler.dispatchMessage(Handler.java:99)
11-11 21:45:39.523: E/AndroidRuntime(881):  at android.os.Looper.loop(Looper.java:137)
11-11 21:45:39.523: E/AndroidRuntime(881):  at android.app.ActivityThread.main(ActivityThread.java:5103)
11-11 21:45:39.523: E/AndroidRuntime(881):  at java.lang.reflect.Method.invokeNative(Native Method)
11-11 21:45:39.523: E/AndroidRuntime(881):  at java.lang.reflect.Method.invoke(Method.java:525)
11-11 21:45:39.523: E/AndroidRuntime(881):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
11-11 21:45:39.523: E/AndroidRuntime(881):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-11 21:45:39.523: E/AndroidRuntime(881):  at dalvik.system.NativeStart.main(Native Method)
11-11 21:45:39.523: E/AndroidRuntime(881): Caused by: android.view.InflateException: Binary XML file line #5: Error inflating class fragment
11-11 21:45:39.523: E/AndroidRuntime(881):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
11-11 21:45:39.523: E/AndroidRuntime(881):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
11-11 21:45:39.523: E/AndroidRuntime(881):  at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
11-11 21:45:39.523: E/AndroidRuntime(881):  at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
11-11 21:45:39.523: E/AndroidRuntime(881):  at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
11-11 21:45:39.523: E/AndroidRuntime(881):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
11-11 21:45:39.523: E/AndroidRuntime(881):  at android.app.Activity.setContentView(Activity.java:1895)
11-11 21:45:39.523: E/AndroidRuntime(881):  at com.example.pis.Peta.onCreate(Peta.java:33)
11-11 21:45:39.523: E/AndroidRuntime(881):  at android.app.Activity.performCreate(Activity.java:5133)
11-11 21:45:39.523: E/AndroidRuntime(881):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
11-11 21:45:39.523: E/AndroidRuntime(881):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
11-11 21:45:39.523: E/AndroidRuntime(881):  ... 11 more


untuk kode programnya Peta.java

package com.example.pis;


import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.view.Menu;
import android.widget.Toast;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class Peta extends  android.support.v4.app.FragmentActivity
{
double      lat, longi;
GoogleMap   myMap;
String[]    lokasi, magnitude;
double lok_latitude=0;
double lok_longitude=0;
String nama;
String alamat;


@Override
protected void onCreate(Bundle savedInstanceState)
{
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.view_map);
 //    setContentView(R.layout.menu_sentra);

    try
    {
        Bundle extras = getIntent().getExtras();
        if (extras!=null){
            lok_latitude = extras.getDouble("Latitude");
            lok_longitude = extras.getDouble("Longitude");
            nama=extras.getString("Nama");
            alamat=extras.getString("Alamat");
            Toast.makeText(Peta.this, lok_latitude + lok_longitude + nama + alamat , Toast.LENGTH_LONG).show();
        }
    } catch (Exception e)
    {
        // TODO: handle exception
    }

    setupMap();
}

private void setupMap()
{
     //membuat fragmentmanager
     FragmentManager myFragmentManager = getSupportFragmentManager();
        SupportMapFragment mySupportMapFragment = (SupportMapFragment)myFragmentManager.findFragmentById(R.id.map);
        myMap = mySupportMapFragment.getMap();
        //membuat Latitude & Longitude dan memberi variable yang bernama tangerang
        LatLng lokasi = new LatLng(lok_latitude, lok_longitude);
        // membuat Pilihan Marker dengan nama variable markertangerang
        MarkerOptions markerLokasi = new MarkerOptions();
        //memngambil Latlang
        markerLokasi.position(lokasi);
        //memberi title ( tulisan di atas )
        markerLokasi.title(nama);
        //memberi tulisan sippet di bawah tittle
        markerLokasi.snippet(alamat);
        //memberi icon yang sudah default dan berwarna hijau ( HUE_GREEN )
        //markertangerang.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));

        //menseting googlemap dengan mode Normal
        myMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
        //menambahkan marker option yang tadi di beri nama markertangerang
        myMap.addMarker(markerLokasi);
        myMap.addMarker(markerLokasi);
        //menambahkan interface compas , 
        myMap.getUiSettings().setCompassEnabled(true);
        //menambahkan interface mode zoom
        myMap.getUiSettings().setZoomControlsEnabled(true);
        //mensetting kamera dengan zoom 15
        myMap.animateCamera(CameraUpdateFactory.newLatLngZoom(lokasi, 15));

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}


sedangkan file layout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Peta">
<fragment
    android:id="@+id/map"
    class="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginTop="16dp" />

sedangkan file manifest :

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

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

<permission
    android:name="com.example.pis.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.example.pis.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />


<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.pis.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name="com.example.pis.Detail"
        android:label="@string/app_name" >
    </activity>

    <activity
        android:name="com.example.pis.Peta"
        android:label="@string/app_name" >
    </activity>

    <activity
        android:name="com.example.pis.Konveksi"
        android:label="@string/app_name" >
    </activity>

    <activity
        android:name="com.example.pis.Makanan"
        android:label="@string/app_name" >
    </activity>

    <activity
        android:name="com.example.pis.Kerajinan"
        android:label="@string/app_name" >
    </activity>

    <activity
        android:name="com.example.pis.Sentra"
        android:label="@string/app_name" >
    </activity>

    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyBcOedYwBVM1mJe-mjDn7ExAxUDhQnoy7g" />
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

 </application>

Kira-kira solusinya bagaimana ya.??? Terima kasih

Menampilkan 1-10 dari 13 hasil
handita okviyanto menjawab 5 tahun yang lalu :

Cek dulu sudah tambahkan library android-support-v4.jar belum? Untuk mengeceknya kayak gini nih

android support

Soalnya com.google.android.gms.maps.SupportMapFragment ada di library tersebut. Yang harus dipahami lagi juga agan harus running di Device yang support android Google Play Services dan versinya mendukung ya.. untuk mengeceknya

Settings -> Apps -> Downloaded -> Google Play Services

google maps


Indra menjawab 5 tahun yang lalu :

cara menambahkan library android-support-v4.jar bagaimana ya.? apakah seperti link ini.??

http://www.twoh.co/2013/04/tutorial-menampilkan-maps-menggunakan-android-maps-api-v2-dan-mapfragment/

error masih muncul seperti diatas..kira2 bagaimana ya..?? terima kasih


handita okviyanto menjawab 5 tahun yang lalu :

Iya bener.. ada error gak di output eclipse lognya.. ? coba dicek biasanya ada log error


Indra menjawab 5 tahun yang lalu :

ini output errornya mas : bagaimana ya solusinya.?? atau nyobanya harus di handphone ?

11-12 21:16:18.137: E/dalvikvm(1087): Could not find class 'com.google.android.gms.maps.SupportMapFragment', referenced from method 

com.example.pis.Peta.setupMap

11-12 21:16:18.137: W/dalvikvm(1087): VFY: unable to resolve check-cast 724 (Lcom/google/android/gms/maps/SupportMapFragment;) in 

Lcom/example/pis/Peta;

11-12 21:16:18.167: D/dalvikvm(1087): VFY: replacing opcode 0x1f at 0x000c
11-12 21:16:18.207: D/dalvikvm(1087): DexOpt: unable to opt direct call 0x131f at 0x1a in Lcom/example/pis/Peta;.setupMap

11-12 21:16:18.237: D/dalvikvm(1087): DexOpt: unable to opt direct call 0x1320 at 0x1f in Lcom/example/pis/Peta;.setupMap

11-12 21:16:19.117: D/AndroidRuntime(1087): Shutting down VM

11-12 21:16:19.147: W/dalvikvm(1087): threadid=1: thread exiting with uncaught exception (group=0x414c4700)

11-12 21:16:19.577: E/AndroidRuntime(1087): FATAL EXCEPTION: main

11-12 21:16:19.577: E/AndroidRuntime(1087): java.lang.RuntimeException: Unable to start activity 

ComponentInfo{com.example.pis/com.example.pis.Peta}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment

11-12 21:16:19.577: E/AndroidRuntime(1087):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at android.os.Looper.loop(Looper.java:137)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at android.app.ActivityThread.main(ActivityThread.java:5103)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at java.lang.reflect.Method.invokeNative(Native Method)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at java.lang.reflect.Method.invoke(Method.java:525)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at dalvik.system.NativeStart.main(Native Method)
11-12 21:16:19.577: E/AndroidRuntime(1087): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class 

fragment

11-12 21:16:19.577: E/AndroidRuntime(1087):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at android.app.Activity.setContentView(Activity.java:1895)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at com.example.pis.Peta.onCreate(Peta.java:32)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at android.app.Activity.performCreate(Activity.java:5133)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
11-12 21:16:19.577: E/AndroidRuntime(1087):     ... 11 more

11-12 21:16:19.577: E/AndroidRuntime(1087): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate 

fragment com.google.android.gms.maps.SupportMapFragment: make sure class name exists, is public, and has an empty constructor that is public
11-12 21:16:19.577: E/AndroidRuntime(1087):     at android.support.v4.app.Fragment.instantiate(Fragment.java:409)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at android.support.v4.app.Fragment.instantiate(Fragment.java:377)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:277)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
11-12 21:16:19.577: E/AndroidRuntime(1087):     ... 21 more
11-12 21:16:19.577: E/AndroidRuntime(1087): Caused by: java.lang.ClassNotFoundException: Didn't find class 

"com.google.android.gms.maps.SupportMapFragment" on path: DexPathList[[zip file 

"/data/app/com.example.pis-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.pis-2, /system/lib]]
11-12 21:16:19.577: E/AndroidRuntime(1087):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
11-12 21:16:19.577: E/AndroidRuntime(1087):     at android.support.v4.app.Fragment.instantiate(Fragment.java:399)
11-12 21:16:19.577: E/AndroidRuntime(1087):     ... 24 more







handita okviyanto menjawab 5 tahun yang lalu :

Iya pastiin dlu coba di hp error gak? Kan ada google servicesnya yang harus dipastiin running.. udah dipastiin belum pake yang emulator androidnya yang support google services..


Indra menjawab 5 tahun yang lalu :

udah saya coba di hp tapi blm bisa juga mas..kira2 kenapa ya.?? apakah perlu saya kirim project saya biar mas handita bisa ngetest runnung....?

Trima kasih.. *maaf banyak nanya ane nubie ttg android..


handita okviyanto menjawab 5 tahun yang lalu :

wah.. ane udah gak install eclipse lagi.. coba cek di outputnya ada compile error gak? ataugak install genymotion yang ada google servicesnya.


Indra menjawab 5 tahun yang lalu :

maksudnya output itu yg mana ya.?? itu saya running di emulator..udah saya jadikan apk juga dan prosesnya sih lancar dan bisa diinstal di hp. tp ya itu saya jalankan aplikasi close lagi.


handita okviyanto menjawab 5 tahun yang lalu :

maksudnya error log yang di eclipse.. di hp juga sama gak errornya? mungkin ada error yang lain..


Indra menjawab 5 tahun yang lalu :

sekarang error yg saya temukan ini mas : kira2 kenapa lagi ya..??

11-17 09:14:55.720: E/AndroidRuntime(1161): FATAL EXCEPTION: main

11-17 09:14:55.720: E/AndroidRuntime(1161): Process: com.example.pis, PID: 1161

11-17 09:14:55.720: E/AndroidRuntime(1161): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.pis/com.example.pis.Peta}:java.lang.NullPointerException

11-17 09:14:55.720: E/AndroidRuntime(1161):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)

11-17 09:14:55.720: E/AndroidRuntime(1161):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)

11-17 09:14:55.720: E/AndroidRuntime(1161):     at android.app.ActivityThread.access$700(ActivityThread.java:135)

11-17 09:14:55.720: E/AndroidRuntime(1161):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)

11-17 09:14:55.720: E/AndroidRuntime(1161):     at android.os.Handler.dispatchMessage(Handler.java:102)

11-17 09:14:55.720: E/AndroidRuntime(1161):     at android.os.Looper.loop(Looper.java:137)

11-17 09:14:55.720: E/AndroidRuntime(1161):     at android.app.ActivityThread.main(ActivityThread.java:4998)

11-17 09:14:55.720: E/AndroidRuntime(1161):     at java.lang.reflect.Method.invokeNative(Native Method)

11-17 09:14:55.720: E/AndroidRuntime(1161):     at java.lang.reflect.Method.invoke(Method.java:515)

11-17 09:14:55.720: E/AndroidRuntime(1161):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)

11-17 09:14:55.720: E/AndroidRuntime(1161):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)

11-17 09:14:55.720: E/AndroidRuntime(1161):     at dalvik.system.NativeStart.main(Native Method)

11-17 09:14:55.720: E/AndroidRuntime(1161): Caused by: java.lang.NullPointerException

11-17 09:14:55.720: E/AndroidRuntime(1161):     at com.example.pis.Peta.setupMap(Peta.java:63)

11-17 09:14:55.720: E/AndroidRuntime(1161):     at com.example.pis.Peta.onCreate(Peta.java:42)

11-17 09:14:55.720: E/AndroidRuntime(1161):     at android.app.Activity.performCreate(Activity.java:5243)

11-17 09:14:55.720: E/AndroidRuntime(1161):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)

11-17 09:14:55.720: E/AndroidRuntime(1161):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)

11-17 09:14:55.720: E/AndroidRuntime(1161):     ... 11 more



Anda harus login terlebih dahulu untuk memberikan komentar

Recent Tag

X 6
X 48
X 14
X 10
X 1
X 5
X 4
X 18
X 10

Bantuan

Help

Feedback

Help