I create a simple widget that presents same data using Pie/Donut Chart (Circle Progress Bar). I wanted to use some external component so I chose:
com.github.lzyzsd.circleprogress.ArcProgress
I placed the ArcProgress component to my widget.xml, I can see it clearly in Preview tab. There is no compilation, build or any other errors. When I run application and put widget to home screen I face an exception:
W/AppWidgetHostView: updateAppWidget couldn't find any view, using error view
android.view.InflateException: Binary XML file line #37: Binary XML file line #37: Error inflating class com.github.lzyzsd.circleprogress.ArcProgress
Caused by: android.view.InflateException: Binary XML file line #37: Error inflating class com.github.lzyzsd.circleprogress.ArcProgress
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.github.lzyzsd.circleprogress.ArcProgress" on path: DexPathList[[zip file "/data/app/com.sec.android.app.launcher-2/base.apk", zip file "/data/app/com.sec.android.app.launcher-2/base.apk"],nativeLibraryDirectories=[/data/app/com.sec.android.app.launcher-2/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.view.LayoutInflater.createView(LayoutInflater.java:616)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:865)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:873)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
at android.view.LayoutInflater.inflate(LayoutInflater.java:525)
at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
at android.widget.RemoteViews.inflateView(RemoteViews.java:3844)
at android.widget.RemoteViews.apply(RemoteViews.java:3808)
at android.appwidget.AppWidgetHostView.applyRemoteViews(AppWidgetHostView.java:456)
at android.appwidget.AppWidgetHostView.updateAppWidget(AppWidgetHostView.java:385)
at com.android.launcher3.home.LauncherAppWidgetHostView.updateAppWidget(LauncherAppWidgetHostView.java:161)
at android.appwidget.AppWidgetHost.updateAppWidgetView(AppWidgetHost.java:418)
at android.appwidget.AppWidgetHost$UpdateHandler.handleMessage(AppWidgetHost.java:136)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
I think that there is some issue with gradle, because my first try was:
az.plainpie.PieView
and result was the same (but ClassNotFound was "az.plainpie.PieView" of course).
My widget.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/widget_margin"
android:background="#AA000000">
<!--xmlns:plainpie="http://schemas.android.com/apk/res-auto"-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/countryView"
android:visibility="visible">
<!-- <az.plainpie.PieView
android:id="@+id/globalValue"
android:layout_width="100dp"
android:layout_height="100dp"
plainpie:inner_pie_padding="10"
plainpie:percentage="75"
plainpie:percentage_size="35"
plainpie:inner_text_visibility="true"/> -->
<com.github.lzyzsd.circleprogress.ArcProgress
android:id="@+id/arc_progress"
android:layout_width="100dp"
android:layout_height="100dp"
app:arc_bottom_text_size="10sp"
app:arc_progress="55"
app:arc_bottom_text="VALUE"/>
<TextView
android:id="@+id/countryText"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="temp"
android:textSize="@dimen/text_size_big"
android:textStyle="bold"
android:textColor="@color/colorWhite"/>
</LinearLayout>
</LinearLayout>
project gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'me.tatarka:gradle-retrolambda:3.6.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
module gradle:
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId 'pl.test.simplewidget'
minSdkVersion 15
targetSdkVersion 25
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
compile group: 'joda-time', name: 'joda-time', version: '2.9.9'
compile 'com.github.zurche:plain-pie:v0.2.1' //pie chart library zurche/plain-pie
compile 'com.github.lzyzsd:circleprogress:1.2.1' // circle progress bar
compile 'com.jakewharton:butterknife:8.6.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
}
I've tried clean project, uninstall application, use different phone. My Android Studio has unchecked "Offline Work" and checked recommended "default gradle wrapper". I searched for solution but none of them solved my issue. Can you see what is wrong?