Ошибка: java.lang.UnsupportedOperationException: невозможно преобразовать в измерение: type = 0x3

Я делаю просто приложение для Android. Но если я хочу запустить приложение, я получаю сообщение об ошибке:

08-15 09:39:33.050: E/AndroidRuntime(871): FATAL EXCEPTION: main 08-15 09:39:33.050: E/AndroidRuntime(871): Process: com.a3gaatleren, PID: 871 08-15 09:39:33.050: E/AndroidRuntime(871): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.a3gaatleren/com.a3gaatleren.MainActivity}: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x3 08-15 09:39:33.050: E/AndroidRuntime(871): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184) 08-15 09:39:33.050: E/AndroidRuntime(871): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) 08-15 09:39:33.050: E/AndroidRuntime(871): at android.app.ActivityThread.access$800(ActivityThread.java:135) 08-15 09:39:33.050: E/AndroidRuntime(871): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 08-15 09:39:33.050: E/AndroidRuntime(871): at android.os.Handler.dispatchMessage(Handler.java:102) 08-15 09:39:33.050: E/AndroidRuntime(871): at android.os.Looper.loop(Looper.java:136) 08-15 09:39:33.050: E/AndroidRuntime(871): at android.app.ActivityThread.main(ActivityThread.java:5001) 08-15 09:39:33.050: E/AndroidRuntime(871): at java.lang.reflect.Method.invokeNative(Native Method) 08-15 09:39:33.050: E/AndroidRuntime(871): at java.lang.reflect.Method.invoke(Method.java:515) 08-15 09:39:33.050: E/AndroidRuntime(871): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 08-15 09:39:33.050: E/AndroidRuntime(871): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 08-15 09:39:33.050: E/AndroidRuntime(871): at dalvik.system.NativeStart.main(Native Method) 08-15 09:39:33.050: E/AndroidRuntime(871): Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x3 08-15 09:39:33.050: E/AndroidRuntime(871): at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:464) 08-15 09:39:33.050: E/AndroidRuntime(871): at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:6129) 08-15 09:39:33.050: E/AndroidRuntime(871): at android.widget.FrameLayout$LayoutParams.<init>(FrameLayout.java:615) 08-15 09:39:33.050: E/AndroidRuntime(871): at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:559) 08-15 09:39:33.050: E/AndroidRuntime(871): at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:56) 08-15 09:39:33.050: E/AndroidRuntime(871): at android.view.LayoutInflater.inflate(LayoutInflater.java:480) 08-15 09:39:33.050: E/AndroidRuntime(871): at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 08-15 09:39:33.050: E/AndroidRuntime(871): at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 08-15 09:39:33.050: E/AndroidRuntime(871): at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249) 08-15 09:39:33.050: E/AndroidRuntime(871): at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106) 08-15 09:39:33.050: E/AndroidRuntime(871): at com.a3gaatleren.MainActivity.onCreate(MainActivity.java:17) 08-15 09:39:33.050: E/AndroidRuntime(871): at android.app.Activity.performCreate(Activity.java:5231) 08-15 09:39:33.050: E/AndroidRuntime(871): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 08-15 09:39:33.050: E/AndroidRuntime(871): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148) 08-15 09:39:33.050: E/AndroidRuntime(871): ... 11 more 08-15 09:39:38.860: I/Process(871): Sending signal. PID: 871 SIG: 9 

Основная деятельность:

 package com.a3gaatleren; import android.support.v7.app.ActionBarActivity; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.webkit.WebView; import android.widget.Button; public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final Button button = (Button) findViewById(R.id.button1); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startActivity(new Intent(MainActivity.this, Samenvattingen.class)); } } ); } @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; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { Intent menuIntent = new Intent(this, Instellingen.class); startActivity(menuIntent); return true; } return super.onOptionsItemSelected(item); } } 

activity_main.xml

 <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" android:layout_marginLeft="@string/marginbutton" android:layout_marginRight="@string/marginbutton" tools:context="com.a3gaatleren.MainActivity" > <Button android:id="@+id/button1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginTop="82dp" android:text="@string/Samenvatting" /> <Button android:id="@+id/button2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/button1" android:text="@string/Woordenlijst" /> <Button android:id="@+id/button3" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/button2" android:text="@string/Agenda" /> <Button android:id="@+id/button4" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/button3" android:text="@string/Instellingen" /> </RelativeLayout> 

Может ли кто-нибудь сказать мне, как решить эту проблему?

PS: Английский не мой первый язык, поэтому я не верю сейчас на английском.

Вы должны определить свои размерные ресурсы, как размеры, а не строки . Итак, переместите @string/marginbutton из @string/marginbutton в res / values ​​/ dimens.xml как

 <?xml version="1.0" encoding="utf-8"?> <resources> <dimen name="marginbutton">8dp</dimen> </resources> 

Ваша ошибка в основном жалуется на передачу ресурса <string> где ожидается <dimen> .

Intereting Posts