Old build.gralde
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.android.support:cardview-v7:22.2.0'
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:design:22.2.0'
When I update appcompat to latset version [23.3.0]:
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
mToolbar.setMenu(mb, new ActionMenuPresenter(getActivity()));
ActionMenuPresenter cannot be resolved.
I found out the source code of ActionMenuPresenter
class ActionMenuPresenter extends BaseMenuPresenter
implements ActionProvider.SubUiVisibilityListener {
private static final String TAG = "ActionMenuPresenter";
private OverflowMenuButton mOverflowButton;
private Drawable mPendingOverflowIcon;
}
Package is default not public.
Please some help me!! How to fix the error.
EDIT:
I found out the solution to fix the question like this:
mToolbar.setOnMenuItemClickListener(
new Toolbar.OnMenuItemClickListener() {
#Override
public boolean onMenuItemClick(MenuItem item) {
return onToolBarOptionsItemSelected(item,
mToolbar.getMenu());
}
});
Related
I found the example of auth in Neura, then created an activity and pasted this code:
public class NeuraActivity extends AppCompatActivity {
private NeuraApiClient mNeuraApiClient;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_neura);
Builder builder = new Builder(getApplicationContext());
mNeuraApiClient = builder.build();
mNeuraApiClient.setAppUid("APP_UID");
mNeuraApiClient.setAppSecret("APP_SECRET"); //here is my app secret, I dont want to show it
mNeuraApiClient.connect();
auth();
}
public void auth() {
mNeuraApiClient.authenticate(new AuthenticateCallback() {
#Override
public void onSuccess(AuthenticateData authenticateData) {
Log.i(getClass().getSimpleName(), "Successfully authenticate with neura. " +
"NeuraUserId = " + authenticateData.getNeuraUserId() + " " +
"AccessToken = " + authenticateData.getAccessToken());
//If you're using firebase for receiving the moment, make sure to call this method.
//Plus, make sure you've registered your firebase server key for your project in our dev site :
//https://dev.theneura.com/docs/guide/android/pushnotification
//If you're putting this code in an activity : ACTIVITY_CONTEXT = YourActivityName.this.
//If you're putting this code in an fragment : ACTIVITY_CONTEXT = getActivity()
mNeuraApiClient.registerFirebaseToken(NeuraActivity.this,
FirebaseInstanceId.getInstance().getToken());
ArrayList<EventDefinition> events = authenticateData.getEvents();
//Subscribe to the events you wish Neura to alert you :
for (int i = 0; i < events.size(); i++) {
mNeuraApiClient.subscribeToEvent(events.get(i).getName(),
"com.chopikus.schoolhelperse" + events.get(i).getName(),
new SubscriptionRequestCallbacks() {
#Override
public void onSuccess(String eventName, Bundle bundle, String s1) {
Log.i(getClass().getSimpleName(), "Successfully subscribed to event " + eventName);
}
#Override
public void onFailure(String eventName, Bundle bundle, int i) {
Log.e(getClass().getSimpleName(), "Failed to subscribe to event " + eventName);
}
});
}
}
#Override
public void onFailure(int i) {
Log.e(getClass().getSimpleName(), "Failed to authenticate with neura. "
+ "Reason : " + SDKUtils.errorCodeToString(i));
}
});
}
}
Here is my gradle dependencies:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// this line must be included to integrate with Firebase
compile 'com.google.firebase:firebase-core:11.0.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.google.firebase:firebase-auth:11.0.1'
compile 'com.google.firebase:firebase-storage:11.0.1'
compile 'com.google.firebase:firebase-database:11.0.1'
compile 'com.google.firebase:firebase-messaging:11.0.1'
compile 'org.apache.directory.studio:org.apache.commons.io:2.4'
compile 'com.koushikdutta.ion:ion:2.+'
compile 'com.github.barteksc:android-pdf-viewer:2.5.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.kenglxn.QRGen:android:2.2.0'
compile 'me.dm7.barcodescanner:zxing:1.9'
compile 'com.google.zxing:core:3.2.1'
compile 'com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.1'
compile 'com.afollestad.material-dialogs:core:0.9.4.5'
compile 'com.github.clans:fab:1.6.2'
compile 'com.google.android.gms:play-services-auth:11.0.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.github.chrisbanes:PhotoView:2.0.0'
compile 'me.grantland:autofittextview:0.2.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.theneura:android-sdk:+'
testCompile 'junit:junit:4.12'
}
And when I start activity I get the error:
java.lang.NoSuchMethodError: No static method zzw(Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzac;
Please help me.
Add this in your gradle
compile "com.google.android.gms:play-services-base:+"
compile 'com.google.android.gms:play-services-location:+'
compile 'com.google.android.gms:play-services-maps:+'
I just added playservices-analytics,base, location, maps library and all is working.
After finding some people saying that FirebaseRecyclerAdapters are broken inside of fragments (and trying for about 4 hours to get it to work before that), I decided to switch to a FirebaseListAdapter, as I found examples of that working inside of fragments. However, I'm having issues. The populateView() method never seems to be firing and I'm getting no errors. Here is my code for the fragment:
public class PasteFromFirebasePopup extends DialogFragment implements AdapterView.OnClickListener {
Activity activity;
private FirebaseListAdapter mFirebaseAdapter;
private DatabaseReference mClipboardHistoryReference;
private ListView mListView;
public PasteFromFirebasePopup() {}
#Override public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.clip_history_popup_list, container, false);
mListView = (ListView) rootView.findViewById(R.id.clipboardHistoryListView);
activity = getActivity();
mClipboardHistoryReference = FirebaseDatabase.getInstance().getReference(Constants.FIREBASE_CHILD_CLIPBOARD_HISTORY);
Log.d("clipboardRef", mClipboardHistoryReference.toString());
mFirebaseAdapter = new FirebaseListAdapter<FirebaseString>
(activity, FirebaseString.class, R.layout.clip_history_popup_item, mClipboardHistoryReference) {
TextView mTextView;
#Override protected void populateView(View v, FirebaseString model, int position) {
mTextView = (TextView) v.findViewById(R.id.clipboardHistoryTextView);
Log.d("model text", model.getText());
mTextView.setText(model.getText());
}
};
mListView.setAdapter(mFirebaseAdapter);
return rootView;
}
#Override public void onClick(View v) {}
#Override public void onDestroy() {
super.onDestroy();
mFirebaseAdapter.cleanup();
}
}
No matter what I try, the log inside of populateView() absolutely never fires. I have triple checked my reference, and there is indeed something in there (only one item at the moment, but as far as I can tell that shouldn't matter). Am I missing something? Does this not work inside of DialogFragments? If not, does anyone have a suggestion for a popup that can hold a FirebaseListAdapter/RecyclerAdapter successfully?
Any help is duly appreciated.
EDIT: my build.gradle (app) , as I think this may have something to do with it.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestCompile('com.android.support.test:runner:0.3') {
exclude group: 'com.android.support', module: 'support-annotations'
}
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.github.smart-fun:XmlToJson:1.2.2'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:gridlayout-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
testCompile 'org.robolectric:robolectric:3.0'
testCompile 'org.robolectric:shadows-support-v4:3.0'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-database:11.0.0'
compile 'com.firebaseui:firebase-ui-database:1.2.0'
compile 'com.google.android.gms:play-services:11.0.0'
compile 'org.parceler:parceler-api:1.1.6'
annotationProcessor 'org.parceler:parceler:1.1.6'
compile 'com.jakewharton:butterknife:8.6.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
}
apply plugin: 'com.google.gms.google-services'
Where can I find the android support library with ActivityCompat.getReferrer() this function ?
I thought it would be in
my build.gradle looks like this: compile 'com.android.support:support-v4:24.0.1' but its not working.
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
//Google
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.google.android.gms:play-services-base:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.android.support:support-v4:24.0.1'
compile 'com.android.support:percent:24.0.0'
}
I am trying to access ActivityCompat.getReferrer() from a activity that extends AppCompatActivity in android.support.v7.app package but I can't find this method
Only compile 'com.android.support:appcompat-v7:24.2.1' is enough for that method as it is a method of ActivityCompat. Please use same versions' of libraries from support library.
Java code sanple
public class SplashActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
Uri uri = ActivityCompat.getReferrer(SplashActivity.this);
if (uri != null)
Toast.makeText(SplashActivity.this,uri.toString(),Toast.LENGTH_SHORT).show();
}
}
Migrating from appcompat-v7:21.0.1 to appcompat-v7:23.1.1 OnPrepareOptionsMenu is not called, now im sad.
Before I migrated the support library there was no issue at all. Then between 2-3 builds/runs(If i add code or add resources) menu suddenly disappears with no errors run-time nor compile time. I LOG onPrepareOptionsMenu calls and as expected it doesn't get called. I tried going back to 21.0.1 but i encountered much more fearsome issues. In-short I cannot go back.
What I always do is do
Build->Clean
And It would show my menu back again.
If this would be helpful I will post what I deem relevant:
dependencies {
// compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/mqttv3-1.0.0.jar')
compile 'com.github.traex.rippleeffect:library:1.3'
provided 'com.squareup.dagger:dagger-compiler:1.2.2'
compile('de.keyboardsurfer.android.widget:crouton:1.8.5#aar') {
// exclusion is not neccessary, but generally a good idea.
exclude group: 'com.google.android', module: 'support-v4'
}
// Google Activity Recognition
// Google Maps
// Google+'
// Google Account Login
dependencies {
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:0.7.4#aar') {
transitive = true
}
}
testCompile 'org.mockito:mockito-core:1.9.5'
testCompile files('libs/dexmaker-mockito-1.0.jar')
testCompile files('libs/dexmaker-1.0.jar')
testCompile 'junit:junit:4.12'
testCompile('org.robolectric:robolectric:3.0') {
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
testCompile 'com.squareup:fest-android:1.0.+'
testCompile 'org.robolectric:shadows-multidex:3.0'
compile('com.crashlytics.sdk.android:crashlytics:2.2.3#aar') {
transitive = true;
}
compile 'com.wdullaer:materialdatetimepicker:1.4.2'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
compile 'com.andreabaccega:android-form-edittext:1.1.0#aar'
compile 'com.shehabic.droppy:Droppy:0.2.5.1#aar'
compile 'com.andreabaccega:android-form-edittext:1.1.0#aar'
compile 'com.github.gcacace:signature-pad:1.0.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.github.anrwatchdog:anrwatchdog:1.1.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.jakewharton:butterknife:6.0.0'
compile 'com.google.code.gson:gson:2.5'
compile 'com.github.bumptech.glide:glide:3.5.2'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.squareup.dagger:dagger:1.2.2'
compile 'com.romainpiel.shimmer:library:1.3.0#aar'
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
compile 'info.hoang8f:fbutton:1.0.5'
compile 'com.wrapp.floatlabelededittext:library:0.0.6'
compile 'com.jpardogo.materialtabstrip:library:1.0.9'
compile 'com.github.markushi:circlebutton:1.1'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-plus:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.sothree.slidinguppanel:library:3.2.0'
compile 'com.daimajia.swipelayout:library:1.1.9#aar'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.0#aar'
compile 'com.daimajia.androidanimations:library:1.1.2#aar'
compile 'com.roomorama:caldroid:1.1.8'
compile 'joda-time:joda-time:2.3'
compile 'com.github.bmelnychuk:atv:1.2.7'
// compile 'org.apache.commons:commons-lang3:3.0'
// compile('com.github.afollestad.material-dialogs:core:0.8.5.+#aar') {
// transitive = true
// }
// compile('com.github.afollestad.material-dialogs:commons:0.8.5.+#aar') {
// transitive = true
// }
compile 'com.github.PhilJay:MPAndroidChart:v2.1.0'
compile 'com.android.support:design:23.1.1'
compile 'com.github.machinarius:preferencefragment:0.1.1'
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.amazonaws:aws-android-sdk-core:2.+'
compile 'com.amazonaws:aws-android-sdk-s3:2.+'
compile project(':commons')
compile project(':core')
}
My MainMenu which extends to AppCompatActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// omitted some butterknife injections
if(mToolbar != null ){
setSupportActionBar(mToolbar);
}
mDrawerToggler = new ActionBarDrawerToggle(this ,mDrawer , mToolbar , R.string.drawer_open , R.string.drawer_close ){
#Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
invalidateOptionsMenu();
}
#Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
invalidateOptionsMenu();
}
};
mDrawer.setDrawerListener(mDrawerToggler);
}
#Override
protected void onRestoreInstanceState(#NonNull Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
final int currentIndex = savedInstanceState.getInt(Constants.CURRENT_POSITION);
selectItem(currentIndex);
}
#Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt(Constants.CURRENT_POSITION, mListView.getSelectedItemPosition());
}
#Override
public boolean onPrepareOptionsMenu(Menu menu) {
boolean drawerOpen = mDrawer.isDrawerOpen(mLeftDrawer);
hideMenuItems(menu, !drawerOpen);
Log.w(TAG , "onPrepareOptionsMenu(Menu menu)" );
return super.onPrepareOptionsMenu(menu);
}
private void hideMenuItems(Menu menu, boolean visible){
for(int i = 0; i < menu.size(); i++){
menu.getItem(i).setVisible(visible);
}
}
private void selectItem(int position){
final ActionBar actionBar = getSupportActionBar();
Fragment frag = null;
// omitted some fragment selection process
if(frag != null){
getSupportFragmentManager().beginTransaction()
.replace(R.id.content_frame, frag)
//.setTransition(FragmentTransaction.TRANSIT_ENTER_MASK)
// commitAllowingStateLoss() instead of commit()
// this is a known bug on API > 11
// http://stackoverflow.com/a/10261449/3974048
.commitAllowingStateLoss();
}
if( position != Constants.A_LOGOUT || position != Constants.S_LOGOUT ) {
mListView.setItemChecked(position, true);
}
mDrawer.closeDrawer(mLeftDrawer);
mCurrentPosition = position;
}
issue in google :
https://code.google.com/p/android/issues/detail?can=1&start=0&num=100&q=onPrepareOptionsMenu&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened&groupby=&sort=&id=172133
My post:
https://code.google.com/p/android/issues/detail?can=5&start=0&num=100&q=&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened&groupby=&sort=&id=199405#makechanges
Im currently using gradle 2.0.0.alhpa6. latest android studio from canary.
I have interface
#GET("/data, 2.5/forecast/daily")
Observable<MultilingualWeather> getWeatherByIdWithMultilingual(
#Query("id") String id,
#Query("lang") String lang,
#Query("appid") String appid);
MainActivity be called up in the following configuration
Retrofit retrofit_weather = new Retrofit.Builder().
baseUrl(BASE_URL).
addConverterFactory(GsonConverterFactory.create()).
addCallAdapterFactory(RxJavaCallAdapterFactory.create()).
build();
GetWeatherForLocation getWeather = retrofit_weather.create(GetWeatherForLocation.class);
Observable<MultilingualWeather> call_observable = getWeather.
getWeatherByIdWithMultilingual(
CITY_ID,
LANG,
KEY
);
subscription = call_observable.subscribe(subscriber);
The following file dependencies
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'io.reactivex:rxjava:1.0.16'
compile 'io.reactivex:rxandroid:1.0.1'
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta1'
}
and after all this takes off exception
FATAL EXCEPTION: main Process: com.example.alex.weatherclient, PID: 16658 java.lang.AbstractMethodError: abstract method "retrofit.CallAdapter retrofit.CallAdapter$Factory.get(java.lang.reflect.Type, java.lang.annotation.Annotation[], retrofit.Retrofit)"
Replace in build.gradle
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta1'
on
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
looks like a typo. Your interface uses getWeatherByIdWithMultilingual and your code uses getWeatherByIdWithMultilingual2