where to find AppCompat.getReferrer() in android support libraries - android

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();
}
}

Related

ViroCore: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/vr/ndk/base/GvrLayout;

I have downloaded ViroCore lib the latest version (virocore-release-v_1_7_2.aar), then I added dependencies below to my build.gradle file
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:25.0.0'
implementation 'com.google.android.exoplayer:exoplayer:r2.2.0'
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
implementation (name:'virocore-release-v_1_7_2', ext: 'aar')
implementation 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-7'
implementation 'com.amazonaws:aws-android-sdk-core:2.2.+'
implementation 'com.amazonaws:aws-android-sdk-ddb:2.2.+'
implementation 'com.amazonaws:aws-android-sdk-ddb-mapper:2.2.+'
implementation 'com.amazonaws:aws-android-sdk-cognito:2.2.+'
implementation 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.2.+'}
and then wrote to my ViroActivity code below:
private ViroView createGVRView() {
return new ViroViewGVR(this, new ViroViewGVR.StartupListener() {
#Override
public void onSuccess() {
onRendererStart();
}
#Override
public void onFailure(ViroViewGVR.StartupError error, String errorMessage) {
onRendererFailed(error.toString(), errorMessage);
}
}, new Runnable() {
#Override
public void run() {
}
});
}
But when run the app, I always see next Exception:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.virosample.gvr.ovr, PID: 17304
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/vr/ndk/base/GvrLayout;
at com.viro.core.ViroViewGVR.init(ViroViewGVR.java:287)
at com.viro.core.ViroViewGVR.<init>(ViroViewGVR.java:211)
at com.example.panorama.ui.view.ViroActivityVR.createGVRView(ViroActivityVR.java:104)
at com.example.panorama.ui.view.ViroActivityVR.onCreate(ViroActivityVR.java:90)
...
Anyone knows how to resolve this exception?
I solved this issue. I added to my dependency just viro library, but I must add additionally both sdk-common.aar and core.aar which you can download at the official virocore site.

FirebaseListAdapter not firing populateView()

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'

Fcm token getting null

i have used following dependencies.
it gives me "Default FirebaseApp is not initialized in this process.Make sure to call FirebaseApp.initializeApp(Context) first."
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'
})
/*compile('org.apache.httpcomponents:httpcore:4.4.1') {
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}*/
/*Button*/
//Google Analytics
//Sweet Alert Dialog
compile('com.google.api-client:google-api-client-android:1.22.0')
compile('com.google.apis:google-api-services-script:v1-rev6-1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
/*Button*/
//Google Analytics
//Sweet Alert Dialog
compile 'pub.devrel:easypermissions:0.1.5'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.github.markushi:circlebutton:1.1'
compile 'com.github.dmytrodanylyk.android-process-button:library:1.0.4'
compile 'cn.pedant.sweetalert:library:1.3'
compile 'me.spark:submitbutton:1.0.1'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.google.firebase:firebase-messaging:9.8.0'
compile 'com.google.android.gms:play-services-auth:9.8.0'
compile 'com.google.android.gms:play-services-appindexing:9.8.0'
testCompile 'junit:junit:4.12'
compile files('libs/org.apache.http.legacy.jar')
}
This has little to do with your dependencies, you'll need to initialize Firebase before using it in your code.
So at the very beginning (Or at least before you make any references to Firebase) add the following:
FirebaseApp.initializeApp(getContext());
In Your Project gradle file put this dependancy
classpath 'com.google.gms:google-services:3.0.0'
and than your module gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.firebase:firebase-messaging:10.0.1'
}
apply plugin: 'com.google.gms.google-services'
it Work for me.
Put this line at the bottom of your app build.gradle file (* last statement)
apply plugin: 'com.google.gms.google-services'
and also check if you are using this dependency in upper gradle file
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
//classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
You have to initialize Firebase befor you use it and best place to initialize it in Application Class
public class App extends BaseApplication {
public static App _appContext = null;
public static final String TAG = App.class.getSimpleName();
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
#Override
public void onCreate() {
super.onCreate();
_appContext = this;
Firebase.setAndroidContext(getApplicationContext());
FirebaseApp.initializeApp(getContext());
}
}
And add it to mainifiest file Application Tag like
<application
android:name="your.path.to.App"
.
.>
Than try and let me know
You can try this
Remove:
Firebase.setAndroidContext(this);
FirebaseApp.initializeApp(this);
And put:
FirebaseDatabase database = FirebaseDatabase.getInstance();

android cannot import actionmenupresenter in appcompat23.3.0

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());
}
});

Migrating from appcompat-v7:21.0.1 to appcompat-v7:23.1.1 now im sad

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.

Categories

Resources