2015-08-25 2 views
0

У меня очень расстроенная ошибка, которую я не могу объяснить. Я создаю приложение для Android. Это XML-проблема.android.view.InflateException: двоичный XML в одном конкретном устройстве

widget_mapa.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:background="@color/quilmes_gray_fafafa" 
android:orientation="vertical"> 

<!-- compact view --> 
<LinearLayout 
    android:id="@+id/compactViewContainer" 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/base_item_size" 
    android:paddingLeft="30dp"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/base_item_size" 
     android:layout_weight="0.4" 
     android:gravity="center_vertical" 
     android:orientation="vertical"> 

     <TextView 
      android:id="@+id/tv_titulo" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_vertical" 
      android:paddingRight="10dp" 
      android:text="Ubicación" 
      android:textColor="@color/quilmes_blue" 
      android:textStyle="bold" /> 


     <TextView 
      android:id="@+id/tv_detalle" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_vertical" 
      android:layout_marginRight="5dp" 
      android:text="geolocalizada" 
      android:textColor="@color/gray" 
      android:textSize="11.5sp" 
      android:textStyle="normal" /> 


    </LinearLayout> 

    <ImageView 
     android:layout_width="@dimen/base_item_size" 
     android:layout_height="@dimen/base_item_size" 
     android:layout_gravity="center" 
     android:layout_marginRight="4dp" 
     android:adjustViewBounds="true" 
     android:scaleType="centerInside" 
     android:src="@drawable/ic_arrow_dark_abajo" /> 
</LinearLayout> 


<!-- full view --> 
<LinearLayout 
    android:id="@+id/fullViewContainer" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:visibility="gone"> 

    <include layout="@layout/double_line_separator" /> 

    <!-- frecuency --> 

    <LinearLayout 
     android:id="@+id/fullFrequencyContainer" 
     android:layout_width="match_parent" 
     android:layout_height="170dp" 
     android:layout_gravity="center_vertical" 
     android:layout_marginBottom="10dp" 
     android:orientation="horizontal" 
     android:weightSum="1.0"> 

     <fragment 
      android:id="@+id/mapView" 
      android:name="com.google.android.gms.maps.MapFragment" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 

    </LinearLayout> 
    </LinearLayout> 
</LinearLayout> 

А вот основной код моей деятельности:

LinearMapa.java

public class LinearMapa extends LinearLayout { 
private Activity activity; 
private Context ctx; 
private Cliente pdv; 

public LinearMapa(Context context, AttributeSet attrs) { 
    super(context, attrs); 
    try { 
     this.ctx = context; 
     this.loadViewComponents(); 
     this.loadListeners(); 
    }catch (Exception e){ 
     e.printStackTrace(); 
    } 
} 

public LinearMapa(Context context, Activity activity,Cliente pdv) { 
    super(context); 
    this.ctx = context; 
    this.activity = activity; 
    this.loadViewComponents(); 
    this.loadListeners(); 
    this.pdv = pdv; 

} 




/** 
* LAYOUT_ID 
*/ 
public static final int LAYOUT_ID = R.layout.widget_mapa; 

/** 
* compactViewContainer 
*/ 
private LinearLayout compactViewContainer; 
private TextView tvTitulo; 
private TextView tv_detalle; 
private LinearLayout fullViewContainer; 

/** 
* compactComerceName 
*/ 
private TextView compactComerceName; 

/** 
* compactAddress 
*/ 
private TextView compactAddress; 


/** 
* compactCodPdv 
*/ 
private TextView compactCodPdv; 


private void loadViewComponents() { 
    try { 
    // generate view 
    (LayoutInflater.from(this.getContext())).inflate(LAYOUT_ID, this); 

    // load UI 
    this.compactViewContainer = (LinearLayout) this.findViewById(R.id.compactViewContainer); 
    this.fullViewContainer = (LinearLayout) this.findViewById(R.id.fullViewContainer); 
    this.tvTitulo = (TextView) this.findViewById(R.id.tv_titulo); 
    this.tv_detalle = (TextView) this.findViewById(R.id.tv_detalle); 

    } 
    catch (Exception e){ 
     e.printStackTrace(); 
    } 
} 

Основная проблема здесь: выше кода запуска гладко на почти устройств (ANDROID KITKAT или LOLLIPOP). Но когда я запускаю его на более низких версиях, ICS приходит к этой ошибке.

.InflateException: Binary XML file line #15: Error inflating class chess.samandroid.view.general.widget.LinearMapa 
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2343) 
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395) 
      at android.app.ActivityThread.access$600(ActivityThread.java:162) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364) 
      at android.os.Handler.dispatchMessage(Handler.java:107) 
      at android.os.Looper.loop(Looper.java:194) 
      at android.app.ActivityThread.main(ActivityThread.java:5392) 
      at java.lang.reflect.Method.invokeNative(Native Method) 
      at java.lang.reflect.Method.invoke(Method.java:525) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
      at dalvik.system.NativeStart.main(Native Method) 
    Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class chess.samandroid.view.general.widget.LinearMapa 
      at android.view.LayoutInflater.createView(LayoutInflater.java:613) 
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687) 
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
      at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:281) 
      at android.app.Activity.setContentView(Activity.java:1881) 
      at chess.samandroid.view.cliente.activities.Cliente.onCreate(Cliente.java:149) 
      at android.app.Activity.performCreate(Activity.java:5122) 
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1084) 
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307) 
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395) 
            at android.app.ActivityThread.access$600(ActivityThread.java:162) 
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364) 
            at android.os.Handler.dispatchMessage(Handler.java:107) 
            at android.os.Looper.loop(Looper.java:194) 
            at android.app.ActivityThread.main(ActivityThread.java:5392) 
            at java.lang.reflect.Method.invokeNative(Native Method) 
            at java.lang.reflect.Method.invoke(Method.java:525) 
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
            at dalvik.system.NativeStart.main(Native Method) 
    Caused by: java.lang.reflect.InvocationTargetException 
      at java.lang.reflect.Constructor.constructNative(Native Method) 
      at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
      at android.view.LayoutInflater.createView(LayoutInflater.java:587) 
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687) 
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:281) 
            at android.app.Activity.setContentView(Activity.java:1881) 
            at chess.samandroid.view.cliente.activities.Cliente.onCreate(Cliente.java:149) 
            at android.app.Activity.performCreate(Activity.java:5122) 
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1084) 
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307) 
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395) 
            at android.app.ActivityThread.access$600(ActivityThread.java:162) 
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364) 
            at android.os.Handler.dispatchMessage(Handler.java:107) 
            at android.os.Looper.loop(Looper.java:194) 
            at android.app.ActivityThread.main(ActivityThread.java:5392) 
            at java.lang.reflect.Method.invokeNative(Native Method) 
            at java.lang.reflect.Method.invoke(Method.java:525) 
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
            at dalvik.system.NativeStart.main(Native Method) 
    Caused by: java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable 
      at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source) 
      at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source) 
      at android.app.Activity.onCreateView(Activity.java:4734) 
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680) 
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
      at chess.samandroid.view.general.widget.LinearMapa.loadViewComponents(LinearMapa.java:92) 
      at chess.samandroid.view.general.widget.LinearMapa.<init>(LinearMapa.java:39) 
            at java.lang.reflect.Constructor.constructNative(Native Method) 
            at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
            at android.view.LayoutInflater.createView(LayoutInflater.java:587) 
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687) 
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:281) 
            at android.app.Activity.setContentView(Activity.java:1881) 
            at chess.samandroid.view.cliente.activities.Cliente.onCreate(Cliente.java:149) 
            at android.app.Activity.performCreate(Activity.java:5122) 
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1084) 
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307) 
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395) 
            at android.app.ActivityThread.access$600(ActivityThread.java:162) 
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364) 
            at android.os.Handler.dispatchMessage(Handler.java:107) 
            at android.os.Looper.loop(Looper.java:194) 
            at android.app.ActivityThread.main(ActivityThread.java:5392) 
            at java.lang.reflect.Method.invokeNative(Native Method) 
            at java.lang.reflect.Method.invoke(Method.java:525) 
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
            at dalvik.system.NativeStart.main(Native Method) 

Gradle

allprojects { 
    repositories { 
     mavenCentral() 
     //maven { url 'http://dt-imac-ba-032:8082/nexus/content/repositories/legacy/' } 
     // flatDir { dirs 'libs' } 

     maven { url 'http://clinker.47deg.com/nexus/content/groups/public' } 
     maven { 
      url "https://oss.sonatype.org/content/repositories/snapshots/" 
     } 
    } 
} 

apply plugin: 'com.android.application' 

dependencies { 
    compile 'com.android.support:appcompat-v7:18.0.+' 
    compile 'com.google.android.gms:play-services:4.0.+' 
    compile fileTree(dir: 'libs', include: '*.jar') 
    compile project(':qRCodeReaderViewlib') 
    compile('com.fortysevendeg.swipelistview:swipelistview:[email protected]') { 
     transitive = true 
    } 
    compile 'com.nineoldandroids:library:2.4.0' 
    compile 'com.android.support:multidex:1.0.0' 
    compile 'com.android.support:support-v4:18.0.+' 
    compile 'com.github.nirhart:parallaxscroll:1.0' 
    compile 'com.j256.ormlite:ormlite-core:4.48' 
    compile 'com.j256.ormlite:ormlite-android:4.48' 
    compile 'commons-lang:commons-lang:2.6' 
    compile 'com.github.amlcurran.showcaseview:library:5.0.0' 
    //compile 'com.android.support:appcompat-v7:22.2.0' 
    //compile 'com.rengwuxian.materialedittext:library:2.1.4' 
} 

android { 
    compileSdkVersion 22 
    buildToolsVersion '22.0.1' 

    compileOptions { 
     encoding "UTF-8" 
     sourceCompatibility JavaVersion.VERSION_1_7 
     targetCompatibility JavaVersion.VERSION_1_7 
    } 
    lintOptions { 
     abortOnError false 
    } 
    dexOptions { 
     javaMaxHeapSize "8g" 
    } 

    signingConfigs { 
     // debug { 
     // storeFile file("../keystore/sam.keystore") 
     //} 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 

    packagingOptions { 
     exclude 'META-INF/DEPENDENCIES.txt' 
     exclude 'META-INF/DEPENDENCIES' 
     exclude 'META-INF/dependencies.txt' 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/license.txt' 
     exclude 'META-INF/LGPL2.1' 
     exclude 'META-INF/NOTICE.txt' 
     exclude 'META-INF/NOTICE' 
     exclude 'META-INF/notice.txt' 
     exclude 'META-INF/INDEX.LIST' 
     exclude 'META-INF/ASL2.0' 
    } 
    defaultConfig { 
     minSdkVersion 14 
     targetSdkVersion 22 
     versionCode 1 
     versionName "2.0.0" 
     renderscriptTargetApi 19 
     renderscriptSupportModeEnabled true 

     // Enabling multidex support. 
     multiDexEnabled true 
    } 
    productFlavors { 
    } 
} 

Скажите, пожалуйста, как исправить ошибки, спасибо :)

+0

java.lang.NoClassDefFoundError: com.google.android.gms.R $ styleable ... вы включили зависимость служб googlePlay в свой файл gradle. Просьба также предоставить файл build.gradle – Ramesh

+0

setContentView (R.layout.LinearMapa) изменить на setContentView (R.layout.widget_mapa); –

+0

добавлено gradle @Ramesh – exequielc

ответ

0

Я думаю, что ваша ошибка исчезнет, ​​если вы используете com.google.android.gms. maps.SupportMapFragment вместо MapFragment.

MapFragment ожидает минимальная версия андроида будет 11. Использование supportMapFragment всякий раз, когда вы хотите пойти ниже SDk версии 11.

0

Исправлено! Решением было изменение jdk1.8.0_40 тоже jdk1.7.0_75 перейти к структуре проекта и изменить jdk 1.8 to jdk1.7 Я не знаю, почему это может привести к этой ошибке. Если кто-то знает, пожалуйста, объясните мне.

+1

Полезно знать вы исправили проблему самостоятельно :) из следующих сообщений выглядит перспективным. Android не поддерживает jdk1.8. http://stackoverflow.com/questions/27622370/android-sdk-for-eclipse-using-google-play-services-lib-error-target-runtime-jr – Ramesh

+0

Да, но это для затмения. В моем случае моя работа в Android Studio – exequielc

Смежные вопросы