Run the new app and getting run time error - android

build.gradle
android {
compileSdkVersion 32
buildToolsVersion "32.0.0"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 21
targetSdkVersion 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
activity_main.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">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
mainactivity.java
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
I just creat new application project and run the app.app not open and get following errror.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: android.view.InflateException: Binary XML file line #27 in com.example.myapplication:layout/abc_screen_toolbar: Binary XML file line #27 in com.example.myapplication:layout/abc_screen_toolbar: Error inflating class androidx.appcompat.widget.ActionBarContainer

Related

Cannot bind view from binding adapter

I'm trying to bind view from adapter but it throws error
xml file
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<data>
<variable
name="accessHistoryItem"
type="com.example.api.model.response.AccessListItem" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="122dp"
android:layout_margin="30dp">
<View
android:id="#+id/borderLine"
android:layout_width="match_parent"
android:layout_height="4dp"
android:background="#color/black"
app:borderLine="#{accessHistoryItem}"
app:layout_constraintBottom_toBottomOf="parent"
tools:layout_editor_absoluteX="0dp"
android:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
binding adapter
#BindingAdapter("borderLine")
fun View.borderLine(item: AccessListItem?){
item.let {
}
exception
Cannot find a setter for <android.view.View app:borderLine> that accepts parameter type 'com.example.api.model.response.AccessListItem'
If a binding adapter provides the setter, check that the adapter is annotated correctly and that the parameter type matches.
Open File
gradle file
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example"
minSdkVersion 28
targetSdkVersion 30
versionCode 19
versionName "0.7.1"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
applicationVariants.all{
variant ->
variant.outputs.each{
output->
project.ext { appName = 'example' }
def formattedDate = new Date().format('dd-MM-yyyy')
// on below line we are creating a new name for our apk.
def newName = output.outputFile.name
newName = newName.replace("app-", "$project.ext.appName-v${variant.versionName}_${variant.versionCode}-$formattedDate-")
output.outputFileName = newName
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
dataBinding{
enabled = true
}
}
dependencies {
implementation project(":api")
//rx
implementation 'io.reactivex.rxjava2:rxjava:2.1.9'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
//gson
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
//glide
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
api 'com.google.android.material:material:1.1.0-alpha06'
apply plugin: 'kotlin-kapt'
}
From your provided code snippets, there doesn't seem to be anything wrong with it. I suspect missing plugin in the app-level build gradle file. Add id 'kotlin-kapt' to the plugins.

databinding msg Could not find accessor within kotlin dataclass

Error message
Found data binding error(s):
[databinding] {"msg":"Could not find accessor com.dubhe.room.entity.User.name","file":"app\\src\\main\\res\\layout\\activity_add_user.xml","pos":[{"line0":31,"col0":28,"line1":31,"col1":36}]}
My layout XML
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import
alias="user"
type="com.dubhe.room.entity.User" />
<variable
name="add"
type="android.view.View.OnClickListener" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="addUser" />
<EditText
android:id="#+id/editUserName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="name"
android:text="#{user.name}" /> <-error in this line.
<EditText
android:id="#+id/editUserAge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="age"
android:inputType="number"
android:text="#{user.age}" />
<Button
android:id="#+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="#{add}"
android:text="Add" />
</LinearLayout>
</layout>
My entity is a kotlin data class.
#Entity(tableName = "user")
data class User(
#PrimaryKey(autoGenerate = true) #ColumnInfo(name = "user_id") var id: Int = 0,
#ColumnInfo(name = "user_name")var name: String = "",
#ColumnInfo(name = "user_age")var age: Int = 0,
#Ignore var isChecked: Boolean = false
)
build.gradle in app directory.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.dubhe.databinding"
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
dataBinding {
enabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.1.0-alpha08'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
// implementation 'com.android.support:support-vector-drawable:29.0.0'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//Room
implementation 'android.arch.persistence.room:runtime:2.1.4'
//BaseRecyclerViewAdapter
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.46'
annotationProcessor 'android.arch.persistence.room:compiler:2.1.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
}
No matter if I clean and rebuild or Invalidate Caches, I can't compile.
You are using an import instead of a variable:
This:
<import alias="user" type="com.dubhe.room.entity.User" />
should be this:
<variable name="user" type="com.dubhe.room.entity.User" />

ARCORE: Sceneform 1.16 issue with rendering

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.

Error while using Dagger2, Room and Databinding

im having issue with this error "error: cannot find symbol class DataBindingComponent" from app/build/generated/source/dataBinding/baseClasses/debug . i have tried all the options people suggested on internet but no help at all.
these options included:
1. clean / rebuild project
2. invalidate caches / restart
1) this is my root build.gradle
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
maven {
url "https://maven.google.com"
}
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "500"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext {
// Sdk and tools
minSdkVersion = 17
devMinSdkVersion = 21;
devPreLollipopSdkVersion = 19;
targetSdkVersion = 27
compileSdkVersion = 27
buildToolsVersion = '27.0.3'
// App dependency
supportLibraryVersion = '27.1.1'
retrofit = "2.3.0"
okHttp = "3.5.0"
butterknife= "8.8.1"
glide = "4.7.1"
glideCompiler = "4.7.1"
rxJava = '2.1.8'
rxAndroid = '2.0.1'
dagger2 = "2.16"
// version
versionCode = 1
versionName = "1.0"
}
2) this is my module build.gradle
`apply plugin: 'com.android.application'
android {
dataBinding {
enabled = true
}
compileSdkVersion rootProject.ext.targetSdkVersion
dexOptions {
maxProcessCount 2
javaMaxHeapSize "2g"
}
defaultConfig {
applicationId "com.movecrop.shipper"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode rootProject.ext.versionCode
versionName rootProject.ext.versionName
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
minifyEnabled false
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "movecrop.shipper"
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:support-v4:$rootProject.supportLibraryVersion"
implementation "com.android.support:customtabs:$rootProject.supportLibraryVersion"
implementation "com.android.support:design:$rootProject.supportLibraryVersion"
implementation "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:multidex:1.0.3'
// glide
implementation "com.github.bumptech.glide:glide:$rootProject.glide"
annotationProcessor "com.github.bumptech.glide:compiler:$rootProject.glideCompiler"
implementation 'jp.wasabeef:glide-transformations:2.0.2'
// retrofit
implementation "com.squareup.retrofit2:retrofit:$rootProject.retrofit"
implementation "com.squareup.retrofit2:retrofit-mock:$rootProject.retrofit"
implementation "com.squareup.retrofit2:converter-gson:$rootProject.retrofit"
implementation "com.squareup.retrofit2:adapter-rxjava2:$rootProject.retrofit"
// okhttp3
implementation "com.squareup.okhttp3:okhttp:$rootProject.okHttp"
implementation "com.squareup.okhttp3:logging-interceptor:$rootProject.okHttp"
implementation 'com.squareup.okio:okio:1.13.0'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'com.orhanobut:hawk:2.0.1'
implementation 'com.jakewharton.byteunits:byteunits:0.9.1'
implementation 'com.github.tajchert:nammu:1.2.0'
// RxJava
implementation "io.reactivex.rxjava2:rxjava:$rootProject.ext.rxJava"
implementation "io.reactivex.rxjava2:rxandroid:$rootProject.ext.rxAndroid"
// Bottom navigation
implementation 'it.sephiroth.android.library.bottomnavigation:bottom-navigation:2.0.1-rc1'
// curl
implementation 'com.github.mrmike:Ok2Curl:master-SNAPSHOT'
// Firebase
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.firebase:firebase-jobdispatcher:0.8.5'
// Dagger2
implementation "com.google.dagger:dagger-android:$rootProject.dagger2"
// Dagger2 if you use the support libraries
implementation "com.google.dagger:dagger-android-support:$rootProject.dagger2"
annotationProcessor "com.google.dagger:dagger-android-processor:$rootProject.dagger2"
annotationProcessor "com.google.dagger:dagger-compiler:$rootProject.dagger2"
def lifecycle_version = "1.1.1"
implementation "android.arch.lifecycle:livedata:$lifecycle_version"
def room_version = "1.1.1"
implementation "android.arch.persistence.room:runtime:$room_version"
annotationProcessor "android.arch.persistence.room:compiler:$room_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'
`
Hope you guys can give me some suggestion, thanks
updated:
This is one of my activity (and its layout xml) that show error:
package com.movecrop.shipper.ui.home;
import android.content.Context;
import android.content.Intent;
import android.databinding.DataBindingComponent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
public class HomeActivity
extends AppCompatActivity
implements HomeViewModel.HomeListener,
SwitchWorkingStatusReceiver.OnSwitchWorkingStatusListener {
private HomeViewModel mHomeViewModel;
ActivityHomeBinding mBinding;
LayoutDrawerHeaderBinding mHeaderBinding;
private ActionBarDrawerToggle mActionBarDrawerToggle;
private SwitchWorkingStatusReceiver mSwitchWorkingStateReceiver = new SwitchWorkingStatusReceiver();
private static final String TAG = "HomeActivity";
public static Intent newIntent(Context context) {
Intent i = new Intent(context, HomeActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_CLEAR_TASK
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
return i;
}
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Injector.getInstance().component().inject(this);
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_home);
mBinding.setHomeActivity(this);
mHomeViewModel = new HomeViewModel();
mHomeViewModel.initialize(this);
LocalBroadcastManager.getInstance(this).registerReceiver(
mSwitchWorkingStateReceiver,
SwitchWorkingStatusReceiver.getIntenFilter()
);
initDrawer();
mHomeViewModel.loadUser();
navigate(R.id.menu_dashboard);
}
}
<layout 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"
tools:context="com.movecrop.shipper.ui.home.HomeActivity">
<data>
<variable
name="homeActivity"
type="com.movecrop.shipper.ui.home.HomeActivity" />
</data>
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:actionBarSize"
app:title="#string/label_dashboard_title" />
<ImageView
android:id="#+id/imgNotification"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="right|center_vertical"
android:cropToPadding="true"
android:padding="12dp"
android:visibility="invisible" />
</FrameLayout>
<FrameLayout
android:id="#+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="#+id/drawerNavigationView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#android:color/white"
android:theme="#style/ThemeOverlay.AppCompat.Light"
app:headerLayout="#layout/layout_drawer_header"
app:itemBackground="#drawable/bg_menu_item_selector"
app:itemIconTint="#color/color_menu_item_selector"
app:itemTextColor="#color/colorDrawerIconTint"
app:menu="#menu/drawer">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical">
<Button
android:id="#+id/btnToggle"
android:layout_width="wrap_content"
android:layout_height="#dimen/button_height"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="32dp"
android:layout_marginRight="32dp"
android:layout_marginTop="40dp"
android:background="#drawable/bg_primary_button_unselected"
android:maxLines="1"
android:onClick="#{homeActivity::click}"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="#string/button_go_online"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="12sp" />
<TextView
android:id="#+id/btnSetting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginTop="32dp"
android:background="#drawable/ts_list_item"
android:drawableLeft="#drawable/ic_dm_setting"
android:drawablePadding="32dp"
android:onClick="#{homeActivity::click}"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:textColor="#color/colorDrawerIconTint"
android:textStyle="bold"
android:fitsSystemWindows="true"
android:text="#string/dm_setting" />
</LinearLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
</layout>
Turns out the error comes from my dao interface for room database not dagger2 neither databinding library. hope it'll help anyone who has same problem.

Android Fresco: Error inflating class com.facebook.samples.zoomable.ZoomableDraweeView

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 .. . !!

Categories

Resources