Can someone help me on this? In my test I want to check if the login button is displayed on the StartPage.
I've been struggling with this error for a while today and I don't know how it should be resolved.What am I missing here?
Maybe this problem is somehow similar to this question:
Espresso test fails with java.lang.String cannot be cast to com.abc.events.databinding.SponsorDetailBinding
android.view.InflateException: Binary XML file line #6: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:770)
at android.view.LayoutInflater.inflate(LayoutInflater.java:483)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
at io.turbela.turbela.login.view.StartActivity.onCreate(StartActivity.java:16)
at android.app.Activity.performCreate(Activity.java:6289)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.support.test.runner.MonitoringInstrumentation.callActivityOnCreate(MonitoringInstrumentation.java:532)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2655)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5951)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void io.turbela.turbela.databinding.FragmentStartBinding.setViewModel(io.turbela.turbela.login.viewmodel.DispatchViewModel)' on a null object reference
at io.turbela.turbela.StartActivityFragment.onCreateView(StartActivityFragment.java:34)
at android.app.Fragment.performCreateView(Fragment.java:2114)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:875)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1060)
at android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1162)
at android.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2131)
at android.app.Activity.onCreateView(Activity.java:5610)
at android.support.v4.app.BaseFragmentActivityHoneycomb.onCreateView(BaseFragmentActivityHoneycomb.java:34)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:79)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:740)
... 20 more
LoginTest.java
#RunWith(AndroidJUnit4.class)
public class LoginTest {
#Rule
public ActivityTestRule<StartActivity> mActivityRule = new ActivityTestRule(StartActivity.class);
#Test
public void displayLoginPage() {
onView(withId(R.id.login_button)).check(matches(isDisplayed()));
}
}
StartActivity.java
public class StartActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start);
}
...onCreateOptionsMenu(...
...onOptionsItemSelected(...
}
activity_start.xml
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/fragment"
class="io.turbela.turbela.StartActivityFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
StartActivityFragment.java
public class StartActivityFragment extends Fragment {
public StartActivityFragment() {
}
public static StartActivityFragment newInstance(){
Bundle args = new Bundle();
args.putString("key", "value");
StartActivityFragment fragment = new StartActivityFragment();
fragment.setArguments(args);
return fragment;
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
FragmentStartBinding binding = DataBindingUtil.inflate(inflater, R.layout.fragment_start, container, false);
binding.setViewModel(new DispatchViewModel());
return binding.getRoot();
}
}
fragment_start.xml
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable name="viewModel" type="io.turbela.turbela.login.viewmodel.DispatchViewModel" />
</data>
<RelativeLayout
style="#android:style/Theme.Holo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<Button
android:id="#+id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginTop="128dp"
android:onClick="#{viewModel.onClickLogin}"
android:text="#string/login" />
</RelativeLayout>
</layout>
DispatchViewModel.java
public class DispatchViewModel extends BaseObservable{
public View.OnClickListener onClickLogin() {
//loginWithEmail
return v -> Log.d("H", "onClickLogin");
}
}
build.gradle
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "io.turbela.turbela"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dataBinding{
enabled = true
}
packagingOptions {
exclude 'LICENSE.txt'
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.parse:parse-android:1.12.0'
compile 'com.parse.bolts:bolts-android:1.3.0'
compile 'com.facebook.android:facebook-android-sdk:4.8.1'
compile 'com.parse:parsefacebookutils-v4-android:1.10.3#aar'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test:runner:0.5'
}
There is android:name attribute missing from <fragment> tag in your activity_start.xml
As per the docs, you must include it.
So your activity.start.xml should look like this:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/fragment"
android:name="io.turbela.turbela.StartActivityFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Note:
The class= attribute you are trying to use is for custom Views as in here
Related
I am using Sceneform 1.16 and andriod studio 4.1,
I am trying to render but it is not working.
Issue:
activity.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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">
<fragment android:name="com.google.ar.sceneform.ux.ArFragment" <======Error ArFragment must be a fragment >
android:id="#+id/ux_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
MainActivity.java.
public class MainActivity extends AppCompatActivity {
private ArFragment arFragment;
private ModelRenderable modelRenderable;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
arFragment = (ArFragment) getSupportFragmentManager().findFragmentById(R.id.ux_fragment);
Error:
Inconvertible types; cannot cast 'androidx.fragment.app.Fragment' to 'com.google.ar.sceneform.ux.ArFragment'
we followed the steps in :
https://github.com/google-ar/sceneform-android-sdk
--Getting started with Sceneform 1.16.0
Can you please tell what is the issue.
Build gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "30.0.1"
defaultConfig {
applicationId "com.examples.myapplication"
minSdkVersion 24
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions{
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
api project(":sceneformux")
}
You should edit the settings.gradle file. Add these lines:
include ':sceneform'
project(':sceneform').projectDir = new File('sceneformsrc/sceneform')
include ':sceneformux'
project(':sceneformux').projectDir = new File('sceneformux/ux')
Do you have a Fragment class that extends the ArFragment? I had it like
<fragment android:name="com.example.zzz.FaceARFragment"
android:id="#+id/face_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
It was a class FaceARFragment extends ArFragment used for configuration only. And in activity:
FaceARFragment arFragment = (FaceARFragment) getSupportFragmentManager().findFragmentById(R.id.face_fragment);
That worked for me. Also you can try using Sceneform 1.17, I tried using 1.16, but 1.17 worked better for me as I was using .glb models.
I read more links about this problem, but i dont know whats exactly problem of my project. i set dataBinding as true on build.gradle, below code is my application build.gradle file content
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.text.myapp"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://clojars.org/repo/" }
}
def support_library = "25.2.0"
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.android.support:appcompat-v7:${support_library}"
compile "com.android.support:support-v13:${support_library}"
compile "com.android.support:cardview-v7:${support_library}"
compile "com.android.support:recyclerview-v7:${support_library}"
}
My activity:
public class ActivityRegister extends AppCompatActivity {
private ActivityRegisterBinding binding;
#Override
public void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_register);
}
}
and then, activity layout
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="presenter"
type="ir.pishguy.cafealachiqpro.Ui.Register.ActivityMain.Model.ActivityRegisterViewModel"/>
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="-5dp"
android:orientation="vertical">
<TextView
android:id="#+id/default_port"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="#dimen/default_textview_height"/>
</LinearLayout>
</layout>
Error on Logcat:
/Users/mahdi/Desktop/Home/Projects/Android/CafeAlachiqPro/app/src/main/java/com/text/myapp/Ui/Register/ActivityMain/Presenter/ActivityRegister.java
Error:(11, 45) error: package com.text.myapp.databinding does not exist
Error:(19, 13) error: cannot find symbol class ActivityRegisterBinding
Warning:The following options were not recognized by any processor:
'[android.databinding.artifactType, android.databinding.printEncodedErrors, android.databinding.minApi, android.databinding.isTestVariant, android.databinding.enableDebugLogs, android.databinding.sdkDir, android.databinding.bindingBuildFolder, android.databinding.enableForTests, android.databinding.modulePackage, android.databinding.generationalFileOutDir, android.databinding.xmlOutDir]'
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
My viewModel:
public class ActivityRegisterViewModel extends BaseObservable {
private String readContactPermission;
private String getMessages;
public ActivityRegisterViewModel() {
}
#Bindable
public String getReadContactPermission() {
return readContactPermission;
}
public void setReadContactPermission(String readContactPermission) {
this.readContactPermission = readContactPermission;
notifyChange();
}
public String getGetMessages() {
return getMessages;
}
public void setGetMessages(String getMessages) {
this.getMessages = getMessages;
}
}
Remove
apply plugin: 'com.neenbedankt.android-apt'
and
apt "com.github.Raizlabs.DBFlow:dbflow-processor:${dbflow_version}"
from gradle. This helps me to get rid of this error.
Although I could run your project cause ir.pishguy.cafealachiqpro.Ui.Register.Robot.Model.RobotViewModel can not be resolved from robot_user_action.xml
<data class="UserMessagesDataBinding">
<variable
name="viewModel"
type="ir.pishguy.cafealachiqpro.Ui.Register.Robot.Model.RobotViewModel">
</variable>
</data>
Please mention the variable tag which defines your viewmodel as follows :
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="<variablename>"
type="<packagename.YourViewModel>" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="-5dp"
android:orientation="vertical">
<TextView
android:id="#+id/default_port"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="#dimen/default_textview_height"/>
</LinearLayout>
</layout>
I'm trying to implement the ButterKnife library in a small project, how ever my app crashes when it starts, details:
here is my MainActivity.java :
package com.example.odai.playwithme;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import butterknife.BindView;
import butterknife.ButterKnife;
public class MainActivity extends AppCompatActivity {
#BindView(R.id.hello_world) TextView hello;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
hello.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "Hello",
Toast.LENGTH_SHORT).show();
}
});
}
}
my activity_main.xml :
<?xml version="1.0" encoding="utf-8"?>
<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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.odai.playwithme.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:id="#+id/hello_world"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
my build.gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.odai.playwithme"
minSdkVersion 17
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.4.0'
compile 'com.jakewharton:butterknife:8.0.1'
}
and this is the error I get whenever I try to run my app :
05-22 20:32:52.019 24076-24076/com.example.odai.playwithme E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.odai.playwithme, PID: 24076
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.odai.playwithme/com.example.odai.playwithme.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2484)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at com.example.odai.playwithme.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:6248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2437)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
any ideas?
I had this problem a while back, too, and actually just tried again to see if it was just a one time thing. Apparently the newer ButterKnife requires a bit more stuff in your build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
apply plugin: 'com.neenbedankt.android-apt'
dependencies {
compile 'com.jakewharton:butterknife:8.0.1'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
}
(https://github.com/JakeWharton/butterknife)
Remove #Bindview line and do the following to bind elements properly:
Click on your layout name in setContentView line
Press alt+enter , it will bring insert options
Click generate butterknief injections
Choose elements that you want to bind
Click ok.
And it will work.
You can also set onclick events directly from there while choosing the views to bind.
I want to create application using Fresco library with zoom functionality using ZoomableDraweeView but when I start my application, application got crashed. Below is my code so please help me to solve this issue and thanks in advance.
public class ZoomActivity extends Activity {
private ZoomableDraweeView view;
private DraweeController ctrl;
private GenericDraweeHierarchy hierarchy;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Fresco.initialize(this);
setContentView(R.layout.activity_zoom);
Uri imageUri = Uri.parse("http://i.imgur.com/76Jfv9b.jpg");
view = (ZoomableDraweeView) findViewById(R.id.zoomable);
ctrl = Fresco.newDraweeControllerBuilder().setUri(imageUri).setTapToRetryEnabled(true).build();
hierarchy = new GenericDraweeHierarchyBuilder(getResources())
.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
.setProgressBarImage(new ProgressBarDrawable())
.build();
view.setController(ctrl);
view.setHierarchy(hierarchy);
}
}
Here is my layout.
<?xml version="1.0" encoding="utf-8"?>
<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="com.example.android.imageloaderexample.Activity.Fresco.ZoomActivity">
<com.facebook.samples.zoomable.ZoomableDraweeView
android:id="#+id/zoomable"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
Here is Gradle.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.android.imageloaderexample"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile files('libs/picasso-2.5.2.jar')
compile files('libs/universal-image-loader-1.9.5.jar')
compile files('libs/glide-3.6.1.jar')
compile 'com.facebook.fresco:fresco:0.10.0'
compile 'com.facebook.fresco:animated-gif:0.10.0'
compile "com.facebook.fresco:imagepipeline-okhttp:0.10.0+"
}
Below is my logcate.
FATAL EXCEPTION: Process: com.example.android.imageloaderexample, PID:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.imageloaderexample/com.example.android.imageloaderexample.Activity.Fresco.ZoomActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class com.facebook.samples.zoomable.ZoomableDraweeView
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)... 23 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack availableBB
<com.example.android.imageloaderexample.Activity.ZoomableDraweeView
android:id="#+id/zoomable"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Please add this Code It is working for me and Enjoy .. . !!
Getting the following error in Android Studio when trying to compile a RecyclerView
android.view.InflateException: Binary XML file line #2: Failed to resolve attribute at index 6: TypedValue{t=0x3/d=0x463 "res/drawable/ic_menu_moreoverflow_material.xml" a=1 r=0x10803d6}
Stacktrace:
12-30 21:01:43.067 32347-32347/com.uk.jacob.containerdroid E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.uk.jacob.containerdroid, PID: 32347
android.view.InflateException: Binary XML file line #2: Failed to resolve attribute at index 6: TypedValue{t=0x3/d=0x463 "res/drawable/ic_menu_moreoverflow_material.xml" a=1 r=0x10803d6}
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.uk.jacob.containerdroid.adapters.ContainerListRecyclerAdapter.onCreateViewHolder(ContainerListRecyclerAdapter.java:48)
at com.uk.jacob.containerdroid.adapters.ContainerListRecyclerAdapter.onCreateViewHolder(ContainerListRecyclerAdapter.java:18)
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:4121)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:3431)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:3340)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1810)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1306)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1269)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:523)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:1988)
at android.support.v7.widget.RecyclerView.resumeRequestLayout(RecyclerView.java:1171)
at android.support.v7.widget.RecyclerView$1.run(RecyclerView.java:167)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:603)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 6: TypedValue{t=0x3/d=0x463 "res/drawable/ic_menu_moreoverflow_material.xml" a=1 r=0x10803d6}
at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:705)
at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:6890)
at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:7071)
at android.support.v7.widget.RecyclerView$LayoutParams.<init>(RecyclerView.java:7018)
at android.support.v7.widget.RecyclerView$LayoutManager.generateLayoutParams(RecyclerView.java:4729)
at android.support.v7.widget.RecyclerView.generateLayoutParams(RecyclerView.java:2349)
at android.view.LayoutInflater.inflate(LayoutInflater.java:502)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.uk.jacob.containerdroid.adapters.ContainerListRecyclerAdapter.onCreateViewHolder(ContainerListRecyclerAdapter.java:48)
at com.uk.jacob.containerdroid.adapters.ContainerListRecyclerAdapter.onCreateViewHolder(ContainerListRecyclerAdapter.java:18)
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:4121)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:3431)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:3340)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1810)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1306)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1269)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:523)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:1988)
at android.support.v7.widget.RecyclerView.resumeRequestLayout(RecyclerView.java:1171)
at android.support.v7.widget.RecyclerView$1.run(RecyclerView.java:167)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:603)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
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:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin" tools:context=".activities.MainActivity">
<android.support.v7.widget.RecyclerView
android:id="#+id/container_list_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"/>
container_list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="?attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp">
<TextView
android:id="#+id/container_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="8dp"/>
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material">
<!-- Customize your theme here. -->
</style>
ContainerListViewRecylerAdapter.java
package com.uk.jacob.containerdroid.adapters;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.uk.jacob.containerdroid.R;
import com.uk.jacob.containerdroid.models.Container;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ContainerListRecyclerAdapter extends RecyclerView.Adapter<ContainerListRecyclerAdapter.ViewHolder> {
private List<Container> mData = new ArrayList<>();
public static class ViewHolder extends RecyclerView.ViewHolder {
public TextView title;
public TextView mTextView;
public ViewHolder(View itemView) {
super(itemView);
title = (TextView) itemView.findViewById(R.id.container_title);
}
}
public void updateList(List<Container> data) {
mData = data;
notifyDataSetChanged();
}
#Override
public int getItemCount() {
return mData.size();
}
#Override
public ContainerListRecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int position) {
View v = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.container_list, viewGroup, false);
ViewHolder vh = new ViewHolder(v);
return vh;
}
#Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.title.setText(mData.get(position).getAliases());
}
public void addItem(int position, Container data) {
mData.add(position, data);
notifyItemInserted(position);
}
}
container_list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="?attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp">
<TextView
android:id="#+id/container_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="8dp"/>
</LinearLayout>
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.uk.jacob.containerdroid"
minSdkVersion 23
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*'])
compile 'com.android.support:appcompat-v7:23.+'
compile 'com.fasterxml.jackson.core:jackson-core:2.4.2'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.4.0'
compile 'com.fasterxml.jackson.core:jackson-databind:2.6.4'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile "com.android.support:support-v4:+"
compile "com.android.support:gridlayout-v7:+"
compile "com.android.support:cardview-v7:+"
compile 'com.android.support:recyclerview-v7:23.1.0'
}
Something wrong in your code file ContainerListAdapter obBindViewHolder which missed an attribute in a drawable xml file ic drawable moreoverflow . Not in the layouts you posted here.