Мое приложение использовало инструмент Gradle версии 3.0.1, и я пытаюсь обновить его до 4.0.1. Однако это приводит к сбою моей сборки из-за того, что я не нашел один из классов привязки.
Я видел некоторые решения в другом вопросе, такие как перестройка, очистка, перезапуск android студии и проблемы с соглашением об именах, ни один из которых казалось, работает.
Я обрезал вывод градиента из-за длины вопроса.
UIBottomBar:
package com.gca.team.gcapp.Model;
import com.gca.team.gcapp.Controller.AppArguments;
public class UIBottomBar {
private boolean processing;
private boolean homeEnabled;
private boolean modeEnabled;
private boolean calibrateEnabled;
private boolean analyzeEnabled;
private boolean retrieveEnabled;
private AppArguments mAppArguments;
public UIBottomBar() {
mAppArguments = AppArguments.getInstance();
refresh();
}
public void refresh() {
boolean isUpdating = mAppArguments.isUpdating();
boolean hasDevice = (mAppArguments.isDeviceAllowed());
boolean hasConfigurationValue = (mAppArguments.getCurrentConfigurationValue() != null);
boolean hasCalibrateValue = (mAppArguments.getCurrentCalibrateValue() != null);
homeEnabled = !isUpdating;
modeEnabled = !isUpdating && hasDevice;
calibrateEnabled = !isUpdating && hasDevice && hasConfigurationValue;
analyzeEnabled = !isUpdating && hasDevice && hasCalibrateValue;
retrieveEnabled = !isUpdating;
}
public void setProcessing(boolean processing) {
this.processing = processing;
}
public boolean isHomeEnabled() { return homeEnabled; }
public boolean isModeEnabled() {
return modeEnabled;
}
public boolean isCalibrateEnabled() {
return calibrateEnabled;
}
public boolean isAnalyzeEnabled() {
return analyzeEnabled;
}
public boolean isRetrieveEnabled() {
return retrieveEnabled;
}
public boolean getProcessing() {
return processing;
}
}
UIBottomBarHandler :
package com.gca.team.gcapp.util;
import android.content.Context;
import android.view.View;
import com.gca.team.gcapp.Activities.AnalyzeDetailsActivity;
import com.gca.team.gcapp.Activities.HomeActivity;
import com.gca.team.gcapp.Activities.ModeActivity;
import com.gca.team.gcapp.Activities.RetrieveActivity;
/**
* Created by tamir on 27/01/2018.
*/
public class UIBottomBarHandler {
public static final int PAIR_SCREEN = 0;
public static final int MODE_SCREEN = 1;
public static final int CALIBRATE_SCREEN = 2;
public static final int ANALYZE_SCREEN = 3;
public static final int RETRIEVE_SCREEN = 4;
public static final int SOFTWARE_UPDATE_SCREEN = 5;
private int currentScreen;
private Context mContext = null;
private UIBottomBarHandlerListener mListener = null;
public UIBottomBarHandler(int currentScreen, Context context) {
mContext = context;
this.currentScreen = currentScreen;
}
public UIBottomBarHandler(int currentScreen, UIBottomBarHandlerListener listener) {
mListener = listener;
this.currentScreen = currentScreen;
}
public void onInProcessClick(View view){
if (null != mListener)
mListener.onInProcessClick();
if (null != mContext) {
Tools.goToActivity(mContext, HomeActivity.class);
}
}
public void onModeClick(View view){
if (currentScreen == MODE_SCREEN)
return;
if (null != mListener)
mListener.onModeClick();
if (null != mContext) {
Tools.goToActivity(mContext, ModeActivity.class);
}
}
public void onCalibrateClick(View view){
if (currentScreen == CALIBRATE_SCREEN)
return;
if (null != mListener)
mListener.onCalibrateClick();
if (null != mContext) {
Tools.goToActivity(mContext, AnalyzeDetailsActivity.class);
}
}
public void onAnalyzeClick(View view){
if (currentScreen == ANALYZE_SCREEN)
return;
if (null != mListener)
mListener.onAnalyzeClick();
if (null != mContext) {
Tools.goToActivity(mContext, AnalyzeDetailsActivity.class);
}
}
public void onRetrieveClick(View view){
if (currentScreen == RETRIEVE_SCREEN)
return;
if (null != mListener)
mListener.onRetrieveClick();
if (null != mContext) {
Tools.goToActivity(mContext, RetrieveActivity.class);
}
}
public void clickAnalyze() {
if (null != mListener)
mListener.onAnalyzeClick();
if (null != mContext) {
Tools.goToActivity(mContext, AnalyzeDetailsActivity.class);
}
}
}
UIBottomBarHandlerListener:
package com.gca.team.gcapp.util;
public interface UIBottomBarHandlerListener {
void onModeClick();
void onCalibrateClick();
void onAnalyzeClick();
void onRetrieveClick();
void onInProcessClick();
}
HomeActivity:
package com.gca.team.gcapp.Activities;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import com.gca.team.gcapp.Controller.AppArguments;
import com.gca.team.gcapp.Model.UIMainItem;
import com.gca.team.gcapp.R;
import com.gca.team.gcapp.databinding.ActivityHomeBinding;
import com.gca.team.gcapp.util.ItemHandler;
import com.gca.team.gcapp.util.ItemHandlerListener;
import com.gca.team.gcapp.util.Tools;
import static com.gca.team.gcapp.Controller.Consts.NULL_INT;
public class HomeActivity extends AppCompatActivity {
public static final String TAG = "HomeActivity: ";
private static final String ACTION_PAIR = "pair";
private static final String ACTION_MODE = "mode";
private static final String ACTION_CALIBRATE = "calibrate";
private static final String ACTION_ANALYZE = "analyze";
private static final String ACTION_RETRIEVE = "retrieve";
AppArguments app_arguments;
BroadcastReceiver uiReceiver;
public static ProgressDialog dialog ;
ActivityHomeBinding binding;
private UIMainItem mPairMainItem;
private UIMainItem mModeMainItem;
private UIMainItem mCalibrateMainItem;
private UIMainItem mAnalyzeMainItem;
private UIMainItem mRetrieveMainItem;
//private EventLogger mEventLogger;
@Override
protected void onResume() {
super.onResume();
setBindings();
checkItemsEnabled();
if (app_arguments.getExternalResultsThc() != NULL_INT) {
Tools.goToActivity(this, AnalyzeActivity.class);
}
}
@Override
public void onBackPressed() {
finish();
}
@Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(uiReceiver);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setContentView(R.layout.activity_home);
app_arguments = AppArguments.getInstance();
//mEventLogger = new EventLogger(this);
final Context context = this;
if(getSupportActionBar()!=null)
uiReceiver = Tools.setCustomActionBar(getSupportActionBar(),this,app_arguments);
mPairMainItem = new UIMainItem("Pair", "", R.drawable.pair_selector);
mModeMainItem = new UIMainItem("Mode", "", R.drawable.mode_selector);
mCalibrateMainItem = new UIMainItem("Calibrate", "", R.drawable.calibrate_selector);
mAnalyzeMainItem = new UIMainItem("Analyze", "", R.drawable.analyze_selector);
mRetrieveMainItem = new UIMainItem("Retrieve", "Browse past analyses results", R.drawable.retrieve_selector);
ItemHandler pairMainItemHandler = new ItemHandler(new ItemHandlerListener() {
@Override
public void onClick() {
//mEventLogger.track("Home - Pair");
doPair();
}
});
ItemHandler modeMainItemHandler = new ItemHandler(new ItemHandlerListener() {
@Override
public void onClick() {
//mEventLogger.track("Home - Mode");
doMode();
}
});
ItemHandler calibrateMainItemHandler = new ItemHandler(new ItemHandlerListener() {
@Override
public void onClick() {
//mEventLogger.track("Home - Calibrate");
doCalibrate();
}
});
ItemHandler analyzeMainItemHandler = new ItemHandler(new ItemHandlerListener() {
@Override
public void onClick() {
//mEventLogger.track("Home - Analyze");
doAnalyze();
}
});
ItemHandler retrieveMainItemHandler = new ItemHandler(new ItemHandlerListener() {
@Override
public void onClick() {
//mEventLogger.track("Home - Retrieve");
doRetrieve();
}
});
binding = DataBindingUtil.setContentView(this, R.layout.activity_home);
setBindings();
binding.setPairMainItemHandler(pairMainItemHandler);
binding.setModeMainItemHandler(modeMainItemHandler);
binding.setCalibrateMainItemHandler(calibrateMainItemHandler);
binding.setAnalyzeMainItemHandler(analyzeMainItemHandler);
binding.setRetrieveMainItemHandler(retrieveMainItemHandler);
checkItemsEnabled();
dialog = ProgressDialog.show(HomeActivity.this, "",
"Loading. Please wait...", true);
dialog.dismiss();
}
private void setBindings() {
binding.setPairMainItem(mPairMainItem);
binding.setModeMainItem(mModeMainItem);
binding.setCalibrateMainItem(mCalibrateMainItem);
binding.setAnalyzeMainItem(mAnalyzeMainItem);
binding.setRetrieveMainItem(mRetrieveMainItem);
}
private void checkItemsEnabled() {
checkIfAnalyzeEnabled();
checkIfPairingEnabled();
checkIfModeEnabled();
checkIfCalibratingEnabled();
}
private void doPair() {
Log.d(TAG,"do pair");
Intent intent = new Intent(this, PairActivity.class);
startActivity(intent);
}
private void enablePair(Boolean enable) {
mPairMainItem.setEnabled(enable);
}
private void doMode() {
Log.d(TAG,"do mode");
Intent intent = new Intent(this, ModeActivity.class);
startActivity(intent);
}
private void enableMode(Boolean enable) {
mModeMainItem.setEnabled(enable);
}
private void doCalibrate() {
Log.d(TAG,"do calibrate");
//starting pairing activity
app_arguments.setPendingCalibrate(true);
Intent intent = new Intent(this, AnalyzeDetailsActivity.class);
startActivity(intent);
}
private void enableCalibrate(Boolean enable) {
mCalibrateMainItem.setEnabled(enable);
}
private void doAnalyze() {
Log.d(TAG,"do analyze");
//starting pairing activity
Intent intent = new Intent(this, AnalyzeFlowerInsertActivity.class);
startActivity(intent);
}
private void enableAnalyze(Boolean enable) {
mAnalyzeMainItem.setEnabled(enable);
}
private void doRetrieve() {
Log.d(TAG,"do retrieve");
//starting pairing activity
Intent intent = new Intent(this, RetrieveActivity.class);
startActivity(intent);
}
private void enableRetrieve(Boolean enable) {
mRetrieveMainItem.setEnabled(enable);
}
private void checkIfModeEnabled()
{
enableMode(app_arguments.isDeviceAllowed());
}
private void checkIfAnalyzeEnabled()
{
enableAnalyze(app_arguments.isDeviceAllowed() && app_arguments.getCurrentCalibrateValue() != null);
}
private void checkIfCalibratingEnabled()
{
enableCalibrate(app_arguments.isDeviceAllowed() && app_arguments.getCurrentConfigurationValue() != null);
}
private void checkIfPairingEnabled()
{
enablePair(true);
}
public void pair(View view) {
//starting pairing activity
Intent intent = new Intent(this, PairActivity.class);
startActivity(intent);
}
}
Домашний макет:
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:bind="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable name="pairMainItem" type="com.gca.team.gcapp.Model.UIMainItem"/>
<variable name="modeMainItem" type="com.gca.team.gcapp.Model.UIMainItem"/>
<variable name="calibrateMainItem" type="com.gca.team.gcapp.Model.UIMainItem"/>
<variable name="analyzeMainItem" type="com.gca.team.gcapp.Model.UIMainItem"/>
<variable name="retrieveMainItem" type="com.gca.team.gcapp.Model.UIMainItem"/>
<variable name="pairMainItemHandler" type="com.gca.team.gcapp.util.ItemHandler"/>
<variable name="modeMainItemHandler" type="com.gca.team.gcapp.util.ItemHandler"/>
<variable name="calibrateMainItemHandler" type="com.gca.team.gcapp.util.ItemHandler"/>
<variable name="analyzeMainItemHandler" type="com.gca.team.gcapp.util.ItemHandler"/>
<variable name="retrieveMainItemHandler" type="com.gca.team.gcapp.util.ItemHandler"/>
</data>
<RelativeLayout
android:id="@+id/activity_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="16dp"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:background="@color/colorPrimary"
tools:context="com.gca.team.gcapp.Activities.HomeActivity">
<LinearLayout
android:id="@+id/content_area"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:weightSum="100">
<include layout="@layout/main_item"
bind:mainItemData="@{pairMainItem}"
bind:mainItemHandler="@{pairMainItemHandler}"
/>
<include layout="@layout/main_item"
bind:mainItemData="@{modeMainItem}"
bind:mainItemHandler="@{modeMainItemHandler}"
/>
<include layout="@layout/main_item"
bind:mainItemData="@{calibrateMainItem}"
bind:mainItemHandler="@{calibrateMainItemHandler}"
/>
<include layout="@layout/main_item"
bind:mainItemData="@{analyzeMainItem}"
bind:mainItemHandler="@{analyzeMainItemHandler}"
/>
<include layout="@layout/main_item"
bind:mainItemData="@{retrieveMainItem}"
bind:mainItemHandler="@{retrieveMainItemHandler}"
/>
</LinearLayout>
</RelativeLayout>
</layout>
ошибка градиента:
11:52:26 AM: Executing task 'compileDebugJavaWithJavac'...
Executing tasks: [compileDebugJavaWithJavac] in project ..
> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:prepareLintJar UP-TO-DATE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:prepareLintJarForPublish UP-TO-DATE
> Task :app:generateDebugSources UP-TO-DATE
> Task :app:dataBindingExportBuildInfoDebug UP-TO-DATE
> Task :app:dataBindingExportFeaturePackageIdsDebug UP-TO-DATE
> Task :app:dataBindingMergeDependencyArtifactsDebug UP-TO-DATE
> Task :app:dataBindingMergeGenClassesDebug UP-TO-DATE
> Task :app:generateDebugResValues UP-TO-DATE
> Task :app:generateDebugResources UP-TO-DATE
> Task :app:mergeDebugResources UP-TO-DATE
> Task :app:dataBindingGenBaseClassesDebug UP-TO-DATE
> Task :app:javaPreCompileDebug UP-TO-DATE
> Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
> Task :app:extractDeepLinksDebug UP-TO-DATE
> Task :app:processDebugManifest UP-TO-DATE
> Task :app:processDebugResources UP-TO-DATE
> Task :app:compileDebugJavaWithJavac
..\app\build\generated\data_binding_base_class_source_out\debug\out\com\gca\team\gcapp\databinding\ActivityHomeBinding.java:14: error: cannot find symbol
import com.gca.team.gcapp.Model;
^
symbol: class Model
location: package com.gca.team.gcapp
..\app\build\generated\data_binding_base_class_source_out\debug\out\com\gca\team\gcapp\databinding\ActivityHomeBinding.java:28: error: package Model does not exist
protected Model.UIMainItem mPairMainItem;
^
..\app\build\generated\data_binding_base_class_source_out\debug\out\com\gca\team\gcapp\databinding\ActivityHomeBinding.java:31: error: package Model does not exist
protected Model.UIMainItem mModeMainItem;
^
..\app\build\generated\data_binding_base_class_source_out\debug\out\com\gca\team\gcapp\databinding\ActivityHomeBinding.java:34: error: package Model does not exist
protected Model.UIMainItem mCalibrateMainItem;
^
..\app\build\generated\data_binding_base_class_source_out\debug\out\com\gca\team\gcapp\databinding\ActivityHomeBinding.java:37: error: package Model does not exist
protected Model.UIMainItem mAnalyzeMainItem;
^
..\app\build\generated\data_binding_base_class_source_out\debug\out\com\gca\team\gcapp\databinding\ActivityHomeBinding.java:40: error: package Model does not exist
protected Model.UIMainItem mRetrieveMainItem;
^
..\app\build\generated\data_binding_base_class_source_out\debug\out\com\gca\team\gcapp\databinding\ActivityHomeBinding.java:64: error: package Model does not exist
public abstract void setPairMainItem(@Nullable Model.UIMainItem pairMainItem);
^
..\app\build\generated\data_binding_base_class_source_out\debug\out\com\gca\team\gcapp\databinding\ActivityHomeBinding.java:67: error: package Model does not exist
public Model.UIMainItem getPairMainItem() {
^
..\app\build\generated\data_binding_base_class_source_out\debug\out\com\gca\team\gcapp\databinding\ActivityHomeBinding.java:71: error: package Model does not exist
public abstract void setModeMainItem(@Nullable Model.UIMainItem modeMainItem);
^
..\app\build\generated\data_binding_base_class_source_out\debug\out\com\gca\team\gcapp\databinding\ActivityHomeBinding.java:74: error: package Model does not exist
public Model.UIMainItem getModeMainItem() {
^
..\app\build\generated\data_binding_base_class_source_out\debug\out\com\gca\team\gcapp\databinding\ActivityHomeBinding.java:78: error: package Model does not exist
public abstract void setCalibrateMainItem(@Nullable Model.UIMainItem calibrateMainItem);
^
..\app\build\generated\data_binding_base_class_source_out\debug\out\com\gca\team\gcapp\databinding\ActivityHomeBinding.java:81: error: package Model does not exist
public Model.UIMainItem getCalibrateMainItem() {
^
..\app\build\generated\data_binding_base_class_source_out\debug\out\com\gca\team\gcapp\databinding\ActivityHomeBinding.java:85: error: package Model does not exist
public abstract void setAnalyzeMainItem(@Nullable Model.UIMainItem analyzeMainItem);
^
..\app\build\generated\data_binding_base_class_source_out\debug\out\com\gca\team\gcapp\databinding\ActivityHomeBinding.java:88: error: package Model does not exist
public Model.UIMainItem getAnalyzeMainItem() {
^
..\app\build\generated\data_binding_base_class_source_out\debug\out\com\gca\team\gcapp\databinding\ActivityHomeBinding.java:92: error: package Model does not exist
public abstract void setRetrieveMainItem(@Nullable Model.UIMainItem retrieveMainItem);
^
..\app\build\generated\data_binding_base_class_source_out\debug\out\com\gca\team\gcapp\databinding\ActivityHomeBinding.java:95: error: package Model does not exist
public Model.UIMainItem getRetrieveMainItem() {
^
..\app\src\main\java\com\gca\team\gcapp\Activities\PairActivity.java:48: error: cannot find symbol
public class PairActivity extends AppCompatActivity implements Bluetooth.DiscoveryCallback {
^
symbol: class DiscoveryCallback
location: class Bluetooth
79 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 3s
> Task :app:compileDebugJavaWithJavac FAILED
16 actionable tasks: 1 executed, 15 up-to-date
11:52:31 AM: Task execution finished 'compileDebugJavaWithJavac'.
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion '29.0.2'
defaultConfig {
applicationId "com.gca.team.gcapp"
minSdkVersion 21
targetSdkVersion 29
versionCode 19
versionName "2.1.5"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/res/assets/'] } }
buildFeatures {
dataBinding true
// for view binding:
viewBinding true
}
// dataBinding {
// enabled = true
// }
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('androidx.test.espresso:espresso-core:3.2.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'me.aflak.libraries:bluetooth:1.3.9'
implementation 'me.aflak.libraries:pulltorefresh:1.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
testImplementation 'junit:junit:4.13'
implementation files('libs/httpclient-4.2.2.jar')
implementation files('libs/httpcore-4.3.2.jar')
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.google.code.gson:gson:2.8.6'
// implementation 'com.mixpanel.android:mixpanel-android:5.+'
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
}
repositories {
mavenCentral()
google()
}
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
свойства gradle
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
gradle-wrapper.properties
#Sun Aug 02 09:13:21 IDT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip