App crushes when add style to TextInputLayout in androidx [duplicate] - java

This question already has answers here:
java.lang.IllegalArgumentException: This component requires that you specify a valid android:textAppearance attribute
(11 answers)
Error : IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents
(13 answers)
Closed 4 years ago.
I'm using an android studio with androidx in the latest version.
I have a TextInputLayout in my app, which makes the app crashes when adding any style to it!
this is my part of xml:
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#style/Widget.MaterialComponents.TextInputLayout.FilledBox">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/saveNameID"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
and this is the logcat error:
2019-01-30 22:41:59.537 1980-1980/hossein.yusefpour.sinamobile E/AndroidRuntime: FATAL EXCEPTION: main
Process: hossein.yusefpour.sinamobile, PID: 1980
android.view.InflateException: Binary XML file line #51: Binary XML file line #51: Error inflating class <unknown>
Caused by: android.view.InflateException: Binary XML file line #51: Error inflating class <unknown>
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
.
.
.
at androidx.fragment.app.FragmentManagerImpl$1.run(FragmentManagerImpl.java:147)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:169)
at android.app.ActivityThread.main(ActivityThread.java:6578)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant).
at com.google.android.material.internal.ThemeEnforcement.checkTheme(ThemeEnforcement.java:240)
at com.google.android.material.internal.ThemeEnforcement.checkMaterialTheme(ThemeEnforcement.java:215)

Related

Invoking on a Null Object Reference -- Android Studio Electric Eel [duplicate]

This question already has answers here:
java - Android Studio - Unable to instantiate activity
(2 answers)
Reason for NullPointerException if setContentView() is not used
(3 answers)
Android App Runtime Error
(2 answers)
Android - Unable to instantiate activity - App has stopped
(1 answer)
Closed 13 days ago.
This post was edited and submitted for review 13 days ago and failed to reopen the post:
Original close reason(s) were not resolved
I'm building an app for a homework assignment here. The app keeps failing to launch because of an error. I know this is for an error that some others have experienced, but I can't understand how to apply it to my own, which is why I'm asking it here.
Here is the error:
AndroidRuntime: FATAL EXCEPTION: main
Process: wesfritz.c196, PID: 4260
java.lang.RuntimeException: Unable to start activity ComponentInfo{wesfritz.c196/wesfritz.c196.UI.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at wesfritz.c196.UI.MainActivity.onCreate(MainActivity.java:21)
at android.app.Activity.performCreate(Activity.java:8000)
at android.app.Activity.performCreate(Activity.java:7984)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601) 
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) 
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7656) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Here's the MainActivity.java code:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//This is how buttons are set up in Android
Button button=this.findViewById(R.id.enterButton);
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this, TermList.class);
//Intent is what connects functions together - makes a thing do a thing!
startActivity(intent);
}
});
setContentView(R.layout.activity_main);
}
Here is what the activity_main.xml looks like:
<TextView
android:id="#+id/textView"
android:layout_width="124dp"
android:layout_height="56dp"
android:fontFamily="sans-serif-condensed-medium"
android:text="StudentApp"
android:textAlignment="center"
android:textAppearance="#style/TextAppearance.AppCompat.Large"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.578" />
<ImageView
android:id="#+id/imageView"
android:layout_width="156dp"
android:layout_height="150dp"
app:layout_constraintBottom_toTopOf="#+id/textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.537"
app:srcCompat="#drawable/ic_launcher_foreground" />
<Button
android:id="#+id/enterButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter"
android:clickable="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView" />
I've tried looking at other examples on here, but they're different and I haven't been able to figure out why mine won't launch. I thought it was because I have a method in a method, but the teacher wrote that code portion. I see that the line that has the problem is the "setOnClickListener" line, but I don't understand. Also, I think "enterButton" is correct across my XML and Java pieces. I'm kind of at a loss.

Error inflating Binary XML file line #53: Error inflating class com.google.android.material.textview.MaterialTextView

Running app on Android version 7.1.1 device. Was working perfectly then suddenly I got this inflation exception error.
XML file:
<com.google.android.material.textview.MaterialTextView
android:id="#+id/titleLogin"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:paddingStart="20dp"
android:paddingTop="20dp"
android:paddingBottom="10dp"
android:text="Login"
android:textColor="#color/black"
android:textSize="34sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0"
app:layout_constraintWidth_percent=".8" />
Logcat:
Caused by: android.view.InflateException: Binary XML file line #53: Binary XML file line #53: Error inflating class com.google.android.material.textview.MaterialTextView
Caused by: android.view.InflateException: Binary XML file line #53: Error inflating class com.google.android.material.textview.MaterialTextView
Caused by: java.lang.reflect.InvocationTargetException
I tried changing MaterialTextView to TextView, did not work.
As I don't have any drawable or layouts imported I don't know why the problem is there. As I said, was working fine one moment and crashed the next.
Does the same with a button as well...
Stack trace:
2022-10-29 21:16:00.512 12386-12386/com.poweredbyralph.southernlines E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.poweredbyralph.southernlines, PID: 12386
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.poweredbyralph.southernlines/com.poweredbyralph.southernlines.LoginActivity}: android.view.InflateException: Binary XML file line #53: Binary XML file line #53: Error inflating class com.google.android.material.textview.MaterialTextView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2798)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2863)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6410)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1084)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:945)
Caused by: android.view.InflateException: Binary XML file line #53: Binary XML file line #53: Error inflating class com.google.android.material.textview.MaterialTextView
Caused by: android.view.InflateException: Binary XML file line #53: Error inflating class com.google.android.material.textview.MaterialTextView
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:710)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195)
at com.poweredbyralph.southernlines.LoginActivity.onCreate(LoginActivity.java:39)
at android.app.Activity.performCreate(Activity.java:6681)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2751)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2863)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6410)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1084)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:945)
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=56; index=930
at android.content.res.StringBlock.get(StringBlock.java:65)
at android.content.res.XmlBlock$Parser.getPooledString(XmlBlock.java:458)
at android.content.res.TypedArray.loadStringValueAt(TypedArray.java:1218)
at android.content.res.TypedArray.getText(TypedArray.java:168)
at android.widget.TextView.<init>(TextView.java:1028)
2022-10-29 21:16:00.512 12386-12386/com.poweredbyralph.southernlines E/AndroidRuntime: at android.widget.TextView.<init>(TextView.java:731)
at androidx.appcompat.widget.AppCompatTextView.<init>(AppCompatTextView.java:108)
at com.google.android.material.textview.MaterialTextView.<init>(MaterialTextView.java:88)
at com.google.android.material.textview.MaterialTextView.<init>(MaterialTextView.java:83)
... 31 more
#CommonsWare, this "The error seems to be complaining about a string resource" actually gave me an idea. I changed my TextViews and Buttons to use strings from the strings file rather than adding them directly.
android:text="Login"
TO:
android:text="#string/login"
Problem solved!!
Thanks for pointing String resource out:)

android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class

I was looking everywhere but I couldn't find any solution for this error.
I'm using ExoPlayer for live video streaming. And my app crashes every time when I run it. If you can help me I will be happy.
I guess it should be somewhere in the XML file but I can't understand what means all that error.
XML:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.devbrackets.android.exomedia.ui.widget.VideoView
android:id="#+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:useDefaultControls="true"/>
</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity file:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setMessage("Please Wait");
progressDialog.setCancelable(false);
progressDialog.show();
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
videoView.setVideoURI(Uri.parse("Here's path"));
videoView.start();
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
progressDialog.dismiss();
}
});
}
}
Stacktrace:
Process: rusiptv.net, PID: 25782
java.lang.RuntimeException: Unable to start activity ComponentInfo{rusiptv.net/rusiptv.net.MainActivity}: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class com.devbrackets.android.exomedia.ui.widget.VideoView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class com.devbrackets.android.exomedia.ui.widget.VideoView
Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class com.devbrackets.android.exomedia.ui.widget.VideoView
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at rusiptv.net.MainActivity.onCreate(MainActivity.java:42)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
If you can please explain to me more detailed about this error because if I will face this problem again then I can fix it easily.
Edit:
Guys thank you, everyone! I fixed this problem.
Solutions:
VideoView videoView = findViewById(R.id.video_view);
And I changed path for VideoView according to my packageName.
Please check whether
<com.devbrackets.android.exomedia.ui.widget.VideoView
android:id="#+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:useDefaultControls="true"/>
path for VideoView is correct according to your packageName.
As i check this file is not complete implement according to user's feedback please try another video view like this
<VideoView
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="#+id/VideoView" />
You Must override the constructor
public VideoPlayerView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
}
This will solve your problem.
Make sure you add the library dependency and must be added this line
VideoView vedioView = findViewById(R.id.video_view);
Before use vedioView. I think it will solve your problem

Java android crash when add android.support.design.widget.NavigationView

When I add this code in activity_main.xml :
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer" />
My app is crashed . Into build gradle, I added a in dependencies :
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
When I remove a android.support.design.widget.NavigationView it is working
This is a log :
Process: com.smok.maps, PID: 16311
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.smok.maps/com.smok.maps.MainActivity}: android.view.InflateException: Binary XML file line #431: Binary XML file line #431: Error inflating class android.support.design.widget.NavigationView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
at android.app.ActivityThread.access$1100(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.view.InflateException: Binary XML file line #431: Binary XML file line #431: Error inflating class android.support.design.widget.NavigationView
at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:474)
at android.app.Activity.setContentView(Activity.java:2387)
at com.smok.maps.MainActivity.onCreate(MainActivity.java:285)
at android.app.Activity.performCreate(Activity.java:6876)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)?
at android.app.ActivityThread.access$1100(ActivityThread.java:221)?
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)?
at android.os.Handler.dispatchMessage(Handler.java:102)?
at android.os.Looper.loop(Looper.java:158)?
at android.app.ActivityThread.main(ActivityThread.java:7224)?
at java.lang.reflect.Method.invoke(Native Method)?
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)?
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)?
Caused by: android.view.InflateException: Binary XML file line #431: Error inflating class android.support.design.widget.NavigationView
at android.view.LayoutInflater.createView(LayoutInflater.java:657)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)?
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)?
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:474)?
at android.app.Activity.setContentView(Activity.java:2387)?
at com.smok.maps.MainActivity.onCreate(MainActivity.java:285)?
at android.app.Activity.performCreate(Activity.java:6876)?
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)?
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)?
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)?
at android.app.ActivityThread.access$1100(ActivityThread.java:221)?
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)?
at android.os.Handler.dispatchMessage(Handler.java:102)?
at android.os.Looper.loop(Looper.java:158)?
at android.app.ActivityThread.main(ActivityThread.java:7224)?
at java.lang.reflect.Method.invoke(Native Method)?
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)?
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)?
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:631)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)?
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)?
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)?
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)?
at android.view.LayoutInflater.inflate(LayoutInflater.java:527)?
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)?
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)?
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:474)?
at android.app.Activity.setContentView(Activity.java:2387)?
at com.smok.maps.MainActivity.onCreate(MainActivity.java:285)?
at android.app.Activity.performCreate(Activity.java:6876)?
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)?
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)?
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)?
at android.app.ActivityThread.access$1100(ActivityThread.java:221)?
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)?
at android.os.Handler.dispatchMessage(Handler.java:102)?
at android.os.Looper.loop(Looper.java:158)?
at android.app.ActivityThread.main(ActivityThread.java:7224)?
at java.lang.reflect.Method.invoke(Native Method)?
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)?
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)?
Caused by: android.view.InflateException: Binary XML file line #17: Binary XML file line #17: Error inflating class android.support.design.internal.NavigationMenuView
at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at android.support.design.internal.NavigationMenuPresenter.getMenuView(NavigationMenuPresenter.java:98)
at android.support.design.widget.NavigationView.<init>(NavigationView.java:161)
at android.support.design.widget.NavigationView.<init>(NavigationView.java:92)
at java.lang.reflect.Constructor.newInstance(Native Method)?
at android.view.LayoutInflater.createView(LayoutInflater.java:631)?
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)?
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)?
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)?
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)?
at android.view.LayoutInflater.inflate(LayoutInflater.java:527)?
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)?
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)?
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:474)?
at android.app.Activity.setContentView(Activity.java:2387)?
at com.smok.maps.MainActivity.onCreate(MainActivity.java:285)?
at android.app.Activity.performCreate(Activity.java:6876)?
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)?
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)?
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)?
at android.app.ActivityThread.access$1100(ActivityThread.java:221)?
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)?
at android.os.Handler.dispatchMessage(Handler.java:102)?
at android.os.Looper.loop(Looper.java:158)?
at android.app.ActivityThread.main(ActivityThread.java:7224)?
at java.lang.reflect.Method.invoke(Native Method)?
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)?
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)?
Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class android.support.design.internal.NavigationMenuView
at android.view.LayoutInflater.createView(LayoutInflater.java:657)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)?
at android.support.design.internal.NavigationMenuPresenter.getMenuView(NavigationMenuPresenter.java:98)?
at android.support.design.widget.NavigationView.<init>(NavigationView.java:161)?
at android.support.design.widget.NavigationView.<init>(NavigationView.java:92)?
at java.lang.reflect.Constructor.newInstance(Native Method)?
at android.view.LayoutInflater.createView(LayoutInflater.java:631)?
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)?
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)?
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)?
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)?
at android.view.LayoutInflater.inflate(LayoutInflater.java:527)?
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)?
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)?
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:474)?
at android.app.Activity.setContentView(Activity.java:2387)?
at com.smok.maps.MainActivity.onCreate(MainActivity.java:285)?
at android.app.Activity.performCreate(Activity.java:6876)?
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)?
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)?
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)?
at android.app.ActivityThread.access$1100(ActivityThread.java:221)?
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)?
at android.os.Handler.dispatchMessage(Handler.java:102)?
at android.os.Looper.loop(Looper.java:158)?
at android.app.ActivityThread.main(ActivityThread.java:7224)?
at java.lang.reflect.Method.invoke(Native Method)?
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)?
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)?
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:631)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)?
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)?
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)?
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)?
at android.support.design.internal.NavigationMenuPresenter.getMenuView(NavigationMenuPresenter.java:98)?
at android.support.design.widget.NavigationView.<init>(NavigationView.java:161)?
at android.support.design.widget.NavigationView.<init>(NavigationView.java:92)?
at java.lang.reflect.Constructor.newInstance(Native Method)?
at android.view.LayoutInflater.createView(LayoutInflater.java:631)?
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)?
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)?
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)?
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)?
at android.view.LayoutInflater.inflate(LayoutInflater.java:527)?
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)?
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)?
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:474)?
at android.app.Activity.setContentView(Activity.java:2387)?
at com.smok.maps.MainActivity.onCreate(MainActivity.java:285)?
at android.app.Activity.performCreate(Activity.java:6876)?
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)?
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)?
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)?
at android.app.ActivityThread.access$1100(ActivityThread.java:221)?
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)?
at android.os.Handler.dispatchMessage(Handler.java:102)?
at android.os.Looper.loop(Looper.java:158)?
at android.app.ActivityThread.main(ActivityThread.java:7224)?
at java.lang.reflect.Method.invoke(Native Method)?
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)?
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)?
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 0: TypedValue{t=0x2/d=0x7f0100b8 a=-1}
at android.content.res.TypedArray.getDrawable(TypedArray.java:883)
at android.widget.AbsListView.<init>(AbsListView.java:1168)
at android.widget.ListView.<init>(ListView.java:
nav_header:
<?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="#dimen/nav_header_height"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:theme="#style/ThemeOverlay.AppCompat.Dark" android:orientation="vertical"
android:gravity="bottom">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="#dimen/nav_header_vertical_spacing"
android:id="#+id/imageView" />
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/nav_header_vertical_spacing"
android:text="Andy Point"
android:textAppearance="#style/TextAppearance.AppCompat.Body1" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="andypoint#androidtutorialpoint.com"
android:id="#+id/textView" />
</LinearLayout>
According to your error its pretty much clear that it has failed to inflate navigation menu. Please provide the #menu/activity_main_drawer file. And recheck it for external Strings or drawables and closed tags.
Well then you should use
<menu xmlns:android="http://schemas.android.com/apk/res/android">
instead of
<menu xmlns:android="schemas.android.com/apk/res/android">
and remove ; after that.
This is a problem of layout_gravity at line number 431 Please try to use layout_gravity = left
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="left"
android:fitsSystemWindows="true" />

Android + jfreeSVG: inheritance issues

I'm developing and Android App with Android Studio. This app makes use of an all-java library module. I've included jfreesvg by adding compile 'org.jfree:jfreesvg:3.1' to the dependencies of said java library module.
Within that java library, I am trying the given example from the main doc for SVGGraphics2D:
SVGGraphics2D g2 = new SVGGraphics2D(300, 200);
g2.setPaint(Color.black);
g2.draw(new Rectangle(10, 10, 280, 180));
String svgElement = g2.getSVGElement();
However, I get two compile errors in Android Studio, the first being in the second line:
setPaint(java.awt.Paint) in SVGGraphics2D cannot be applied to (java.awt.Color)
Also, in the next line, the following error with, I suppose the same cause, occurrs: draw(java.awt.Paint) in SVGGraphics2D cannot be applied to (java.awt.Color)
My question now is: Even though java.awt.Paint is an Interface and java.awt.Color is an implementation of that interface, why do I get that error (and the same for java.awt.Shape and java.awt.Rectangle)?
For the sake of completion: If I do run the app, which I'm confused about that it works, I get the following Exception:
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: [package].app, PID: 19596
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:811)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/jfree/graphics2d/svg/SVGGraphics2D;
at [package].[some.package].someMethod(Unknown)
at [package].app.MainActivity$SomeTask.doInBackground(MainActivity.java:67)
at [package].app.MainActivity$SomeTask.doInBackground(MainActivity.java:62)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
at java.lang.Thread.run(Thread.java:811) 
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.jfree.graphics2d.svg.SVGGraphics2D" on path: DexPathList[[zip file "/data/app/[package].app-2.apk"],nativeLibraryDirectories=[/data/app-lib/[package].app-2, /system/lib, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at [package].[some.package].someMethod(Unknown) 
at [package].app.MainActivity$SomeTask.doInBackground(MainActivity.java:67) 
at [package].app.MainActivity$SomeTask.doInBackground(MainActivity.java:62) 
at android.os.AsyncTask$2.call(AsyncTask.java:288) 
at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
at java.lang.Thread.run(Thread.java:811) 
Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/Graphics2D;
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:222)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:215)
at dalvik.system.DexPathList.findClass(DexPathList.java:322)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
... 11 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.awt.Graphics2D" on path: DexPathList[[zip file "/data/app/[package].app-2.apk"],nativeLibraryDirectories=[/data/app-lib/[package].app-2, /system/lib, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
... 16 more
Suppressed: java.lang.ClassNotFoundException: java.awt.Graphics2D
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 17 more
Caused by: java.lang.NoClassDefFoundError: Class "Ljava/awt/Graphics2D;" not found
... 21 more
Suppressed: java.lang.ClassNotFoundException: org.jfree.graphics2d.svg.SVGGraphics2D
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 10 more
Caused by: java.lang.NoClassDefFoundError: Class "Lorg/jfree/graphics2d/svg/SVGGraphics2D;" not found
... 14 more
(I edited the stack trace for better readability.)
The java.awt.* package is not available in Android. So the library that you are trying to use cannot be used directly in your Android app. At least not without further work.
You would need to implement those classes yourself, or source them from somewhere else, such as from the Apache Harmony project.

Categories