【发布时间】:2016-07-11 12:13:31
【问题描述】:
我的同事使用classpath 'com.android.tools.build:gradle:1.1.0' 在 Android Studio 1.4 的 API 21 上开发了一个 Android 应用程序。另外,他使用的是Java jdk1.7.0_75。
现在我需要继续这个项目的工作。但我使用的是 Android Studio 2.1.1,并且想使用 API 22 或 23。我的 gradle 版本是 classpath 'com.android.tools.build:gradle:2.1.0',我使用的是 Java jdk1.8.0_91。
如果我尝试在与他相同的 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.
-
出了什么问题:
任务“:app:compileDebugJavaWithJavac”执行失败。 编译失败;有关详细信息,请参阅编译器错误输出。
-
尝试: 使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。
构建失败
总时间:1 分 40.139 秒
我不知道问题出在哪里,因为如果我尝试使用他的笔记本电脑(使用他的旧版 Android Studio ..)运行该应用程序,该应用程序可以运行!
谁能解释错误
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.)
更新
@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);
}
最后一个 if(现在已注释)是我得到错误的地方:
data.get(userDatabaseAdapter.ACCESS_NAME) == 1
来自 Android Studio 的提示是:
通过实例引用访问的静态成员“z550583.com.sql.UserDatabaseAdapter.ACCESS_NAME”。通过类实例而不是类本身显示对静态方法和字段的引用。
但同样的提示也出现在旧版 Android Studio 中。所以我不确定这是否是唯一的问题。
【问题讨论】:
-
您的代码中有错误,请分享您遇到错误的文件,如上述错误的
ConnectFragment.java。 -
您可以重新安装应用程序吗?卸载旧版本?
-
我用代码@AshishRanjan 添加了一个答案!但我应该使用新版本
-
您可以将代码添加到问题本身,而不是将其作为答案发布。
标签: java android android-studio gradle