Мой коллега работал над Android-приложением по API 21 в Android Studio 1.4 с classpath 'com.android.tools.build:gradle:1.1.0'
. Кроме того, он использовал Java jdk1.7.0_75.Gradle Проблемы с созданием в Android Studio
И теперь мне нужно продолжить работу над этим проектом. Но у меня есть Android Studio 2.1.1 и вы хотите работать с API 22 или 23. Моя версия градиента - classpath 'com.android.tools.build:gradle:2.1.0'
, и я использую Java jdk1.8.0_91.
Если я пытаюсь «Run» приложение на том же устройстве Android, как он сделал, я получаю эту ошибку:
Executing tasks: [:app:assembleDebug]
Configuration on demand is an incubating feature.
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72100Library
:app:prepareComAndroidSupportRecyclerviewV72100Library
:app:prepareComAndroidSupportSupportV42100Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources
:app:mergeDebugResources
:app:processDebugManifest
:app:processDebugResources
:app:generateDebugSources
:app:incrementalDebugJavaCompilationSafeguard
:app:compileDebugJavaWithJavac
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
C:\Users\z565719\AndroidStudioProjects\DrescherBluetoothCanCom\app\src\main\java\z550583\com\navigationdrawer\ConnectFragment.java:133: error: incomparable types: Object and int
if (data.get(userDatabaseAdapter.ACCESS_NAME) == 1) {
^
[24 more errors like the one above...]
^
Note: C:\Users\z565719\AndroidStudioProjects\DrescherBluetoothCanCom\app\src\main\java\z550583\com\navigationdrawer\MainActivity.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
25 errors
:app:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
Что пошло не так:
выполнение Сбой задачи " : приложение: compileDebugJavaWithJavac. Ошибка компиляции; см. вывод ошибки компилятора.
Попробуйте: Запустите с опцией --stacktrace, чтобы получить трассировку стека. Запустите с опцией --info или --debug, чтобы получить больше выходных данных журнала.
BUILD FAILED
Общее время: 1 мин 40.139 ИКС
Я не знаю, где эта проблема в том, что если я пытаюсь запустить приложение с его ноутбуком (с его старой студии Android ..) приложение работает!
Может кто-то интерпретировать ошибку
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.)
UPDATE
@AshishRanjan просил файла. Вот мой ConnectFragment.java:
public class ConnectFragment extends Fragment {
private View rootView;
private Toolbar mToolbar;
private BluetoothComService bluetoothComService;
private boolean isBound = false;
private TextView tvDiConDi;
private ProgressBar pb;
private int CurrentInitProgress = 0;
private int PastInitProgress = 0;
private boolean connectionDetailClicked;
private ImageView ivConnectionDetail;
private ToggleButton tglConnect;
private EditText eTBaudRate;
private EditText eTDbcName;
private LinearLayout LLShowDetail;
private LinearLayout LLConnectToggle;
private LinearLayout LLBaudRate;
private UserDatabaseAdapter userDatabaseAdapter;
private HashMap data;
private ConnectThread connectThread;
private boolean displayThreadLoop = true;
private ServiceConnection mConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName className, IBinder service) {
BluetoothComService.LocalBinder binder = (BluetoothComService.LocalBinder) service;
bluetoothComService = binder.getService();
isBound = true;
}
@Override
public void onServiceDisconnected(ComponentName name) {
isBound = false;
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public void onStart() {
super.onStart();
// Bindet an den BluetoothService
Intent intent = new Intent(getActivity(), BluetoothComService.class);
getActivity().bindService(intent, mConnection, getActivity().getApplicationContext().BIND_AUTO_CREATE);
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.fragment_connect, container, false);
tvDiConDi = (TextView) rootView.findViewById(R.id.tv_display_connect_description);
ivConnectionDetail = (ImageView) rootView.findViewById(R.id.arrow_connection_details);
pb = (ProgressBar) rootView.findViewById(R.id.progress_bar_connect);
pb.setProgress(StateSingleton.getInstance().getProgressConnectState());
eTBaudRate = (EditText) rootView.findViewById(R.id.edit_baud_rate);
eTDbcName = (EditText) rootView.findViewById(R.id.edit_dbc_name);
LLBaudRate = (LinearLayout) rootView.findViewById(R.id.linear_layout_baud_rate);
LLShowDetail = (LinearLayout) rootView.findViewById(R.id.linear_layout_show_detail);
LLConnectToggle = (LinearLayout) rootView.findViewById(R.id.linear_layout_connect_toggle);
tglConnect = (ToggleButton) rootView.findViewById(R.id.connect_toggle);
tglConnect.setChecked(StateSingleton.getInstance().getTglConnectState());
tglConnect.playSoundEffect(SoundEffectConstants.CLICK);
userDatabaseAdapter = new UserDatabaseAdapter(getActivity());
data = userDatabaseAdapter.getFragmentData(InfoSingleton.getInstance().getUserName());
mToolbar = (Toolbar) getActivity().findViewById(R.id.toolbar_actionbar);
//if (data.get(userDatabaseAdapter.ACCESS_NAME) == 1) {
// LLBaudRate.setVisibility(View.VISIBLE);
//}
int ersterInteger = (int) data.get(UserDatabaseAdapter.ACCESS_NAME);
if (ersterInteger == 1){
LLBaudRate.setVisibility(View.VISIBLE);
}
Последнее, если (теперь комментировал), где я получил ошибку:
data.get (userDatabaseAdapter.ACCESS_NAME) == 1
подсказка от Android Studio:
Статический член 'z550583.com.sql.UserDatabaseAdapter.ACCESS_NAME' обратился через ссылку экземпляра. Показывает ссылки на статические методы и поля через экземпляр класса, а не на сам класс.
Но тот же намек также показан в старой версии Android Studio. Поэтому я не уверен, что это единственная проблема.
у Вас есть ошибки в кода, поделитесь файлами, в которых вы получаете ошибки, например 'ConnectFragment.java' для вышеуказанной ошибки. –
Можете ли вы просто установить приложение заново? Удалить старую версию? – Eenvincible
Я добавил ответ с кодом @AshishRanjan! Но я должен работать с новой версией – TeaAge