我正在尝试使用HoloCircularProgressBar by Pascal Welsch并且它在Android Studio中给我提出问题(v0.5.3,因为它的价值,当我使用Eclipse时它并没有给我任何问题,而且我没有' t在迁移期间改变任何东西)并且当它试图从布局XML中膨胀时我一直收到这个错误:
Caused by: java.lang.NoSuchFieldError: de.passsy.holocircularprogressbar.R$attr.circularProgressBarStyle
at de.passsy.holocircularprogressbar.HoloCircularProgressBar.<init>(HoloCircularProgressBar.java:218)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at com.mavensay.rithm.fragments.RecordVideoFragment.onCreateView(RecordVideoFragment.java:113)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:938)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1115)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1478)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:570)
at com.mavensay.rithm.RecordVideoV2.onStart(RecordVideoV2.java:42)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1194)
at android.app.Activity.performStart(Activity.java:5258)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2182)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5102)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
我的XML布局:
...
<de.passsy.holocircularprogressbar.HoloCircularProgressBar
android:id="@+id/recordingProgress"
android:layout_width="110dp"
android:layout_height="110dp"
android:layout_centerInParent="true"
app:marker_visible="false"
app:progress_background_color="@color/lt_grey"
app:progress_color="@color/landingPageStartColor"
app:thumb_visible="false" />
...
这是HoloCircularProgressBar的相关代码
/**
* Instantiates a new holo circular progress bar.
*
* @param context
* the context
* @param attrs
* the attrs
*/
public HoloCircularProgressBar(final Context context, final AttributeSet attrs) {
// line 218 vv
this(context, attrs, R.attr.circularProgressBarStyle);
}
/**
* Instantiates a new holo circular progress bar.
*
* @param context
* the context
* @param attrs
* the attrs
* @param defStyle
* the def style
*/
public HoloCircularProgressBar(final Context context, final AttributeSet attrs, final int defStyle) {
super(context, attrs, defStyle);
// load the styled attributes and set their properties
final TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.HoloCircularProgressBar,
defStyle, 0);
setProgressColor(attributes.getColor(R.styleable.HoloCircularProgressBar_progress_color, Color.CYAN));
setProgressBackgroundColor(attributes.getColor(R.styleable.HoloCircularProgressBar_progress_background_color,
Color.MAGENTA));
setProgress(attributes.getFloat(R.styleable.HoloCircularProgressBar_progress, 0.0f));
setMarkerProgress(attributes.getFloat(R.styleable.HoloCircularProgressBar_marker_progress, 0.0f));
setWheelSize((int) attributes.getDimension(R.styleable.HoloCircularProgressBar_stroke_width, 10));
mIsThumbEnabled = attributes.getBoolean(R.styleable.HoloCircularProgressBar_thumb_visible, true);
mIsMarkerEnabled = attributes.getBoolean(R.styleable.HoloCircularProgressBar_marker_visible, true);
mGravity = attributes.getInt(R.styleable.HoloCircularProgressBar_android_gravity, Gravity.CENTER);
attributes.recycle();
mThumbRadius = mCircleStrokeWidth * 2;
updateBackgroundColor();
updateMarkerColor();
updateProgressColor();
// the view has now all properties and can be drawn
mIsInitializing = false;
}
主模块的build.gradle:
apply plugin: 'android'
apply from: 'signing.gradle'
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.release
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
dependencies {
compile 'com.android.support:support-v4:+'
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:+'
compile 'com.google.code.gson:gson:2.2.2'
compile 'com.android.support:appcompat-v7:19.+'
compile project(':devsmartAndroid')
compile project(':facebookSDK')
compile project(':library') // <-- this is HoloCircularProgressBar
compile "com.mixpanel.android:mixpanel-android:4.0.0@aar"
compile project(':rithmLibrary')
compile files('libs/bugsense-3.6.jar')
compile files('libs/flurryAnalytics_3.4.0.jar')
compile files('libs/httpmime-4.1.1.jar')
compile files('libs/isoviewer-1.0-RC-28.jar')
compile files('libs/picasso-2.1.1.jar')
compile files('libs/simple-xml-2.7.1.jar')
compile files('libs/tapjoyconnectlibrary.jar')
compile files('libs/twitter4j-core-3.0.3.jar')
compile files('libs/urbanairship-lib-3.2.2.jar')
}
HoloCircularProgressBar的build.gradle:
apply plugin: 'android-library'
android {
compileSdkVersion 17
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 8
targetSdkVersion 17
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
项目的settings.gradle:
include ':devsmartAndroid'
include ':facebookSDK'
include ':rithmLibrary'
include ':library' // <-- this is HoloCircularProgressBar
include ':main'
include ':rithm'
感谢任何帮助:)