0
I created a project and did not put anything in it, the same is zeroed, only with that textView "Hello World". The problem appeared when I tried to add a Fragment (with a + 1 button) to the project:
Already gave refresh and nothing. When I try to start the app, gives this in the log:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
I didn’t change anything in both the initial Activity and Fragment, it follows their code respectively:
package genesysgeneration.frag;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Fragment:
package genesysgeneration.frag;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.gms.plus.PlusOneButton;
/**
* A fragment with a Google +1 button.
* Activities that contain this fragment must implement the
* {@link One.OnFragmentInteractionListener} interface
* to handle interaction events.
* Use the {@link One#newInstance} factory method to
* create an instance of this fragment.
*/
public class One extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// The request code must be 0 or greater.
private static final int PLUS_ONE_REQUEST_CODE = 0;
// The URL to +1. Must be a valid URL.
private final String PLUS_ONE_URL = "http://developer.android.com";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private PlusOneButton mPlusOneButton;
private OnFragmentInteractionListener mListener;
public One() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment One.
*/
// TODO: Rename and change types and number of parameters
public static One newInstance(String param1, String param2) {
One fragment = new One();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_one, container, false);
//Find the +1 button
mPlusOneButton = (PlusOneButton) view.findViewById(R.id.plus_one_button);
return view;
}
@Override
public void onResume() {
super.onResume();
// Refresh the state of the +1 button each time the activity receives focus.
mPlusOneButton.initialize(PLUS_ONE_URL, PLUS_ONE_REQUEST_CODE);
}
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
}
try to add the
multiDexEnabled true
in the grandle.– viana
still giving error in the log
– Boneco Sinforoso
Look at that answer: http://stackoverflow.com/a/34284213/2570426
– viana
There was progress, did not stop the startup, the log did not present anything at first, however the app Unfortunately has sttoped.
– Boneco Sinforoso