当我尝试运行下面显示的代码时出现编译错误:
package com.example.dude.googleapi;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.drive.Drive;
public class MainActivity extends ActionBarActivity implements GoogleApiClient.OnConnectionFailedListener,GoogleApiClient.ConnectionCallbacks{
GoogleApiClient mGoogleApiClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GDriveLogin();
}
void GDriveLogin(){
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
}
@Override
public void onConnected(Bundle bundle) {
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
protected void onStart() {
super.onStart();
mGoogleApiClient.connect();
}
}
这些是我添加到Gradle文件中的依赖项:
compile files('libs/android-support-v4.jar')
compile 'com.google.android.gms:play-services:6.5.87'
并且,清单文件中的节点:
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
并且,这是我得到的唯一编译错误:
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/v4/app/NotificationCompatIceCreamSandwich.class
有人可以帮助解决这个问题吗?