React Native Android - development server response error code 500 - android

Learning react-native and currently following IG clone tutorial on my android device from this youtube video - https://www.youtube.com/watch?v=cgg1HidN4mQ
I have come stuck in this. Attached image is something I've been trying to fix for hours with no luck...
https://imgur.com/a/u8Kmw
Does anybody know what would be the cause of this? Here is the code...
https://github.com/crt434/React_IG_Copy

See this code in your Mainscreen.js
import HomeTab from './AppTabNavigator/HomeTab'
import SearchTab from './AppTabNavigator/SearchTab'
import AddMediaTab from './AppTabNavigator/AddMediaTab'
import LikesTab from './AppTabNavigator/LikesTab'
import ProfileTab from './AppTabNavigator/ProfileTab'
All these paths are missing. there is no AppTabNavigator folder.

Related

Why react native can`t find image in assets folder?

I have a background image in src/assets folder which I try to get access to from src/screens/splash/index.js as such:
import {ImageBackground} from 'react-native';
import React from 'react';
export default function SplashScreen() {
return (
<ImageBackground
source={require('../../assets/bg1.jpg')}
resizeMode={'cover'}
style={{flex: 1}}>
</ImageBackground>
);
}
Returns this error:
None of these files exist:
bg1.jpg
src\assets\bg1.jpg\index(.native|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
If i move the image in any other folder, for example screens and change source to:
source={require('../../screens/bg1.jpg')}
its working fine.
Im baffled and wondering the reason behind it?
Is it maybe because I use react-native cli and renamed the tsx file created originally to js?
Here is a picture in case it helps understanding the problem.
After trying everyting was suggested in the comments, nothing has worked so far. I went ahead and continue building the app (following a tutorial) and re-compiled the application, now on an other computer and it started working!
The only change that I made since added the assets folder and the image that following the documentation integration-with-android-fragment I added few extra lines to MainActivity.java as suggested.
import android.os.Bundle;
and
private Bundle getLaunchOptions(String message) {
Bundle initialProperties = new Bundle();
initialProperties.putString("message", message);
return initialProperties;
}
Now im not 100% sure this was the solution to the problem, but I assume it must have been as no other changes has been made to the code since the error message appeared..
That is also possible that on my other computer it still wouldnt work, so the error is rooted somewhere within how my computer handeled these packadges. Unfortunately Im unable to test this theory for the next 2 weeks, but will share it whatever it concludes.

visual studio android import cant resolved after update

I updated Visual Studio, then my Android project had errors such as import could not be resolved. It could not be resolved to a text type. The type could not be resolved. Then I created a new project with the same settings. However, it had the same errors. It does not work because of the code, but maybe it knows who knows the code here.
package com.Android2;
import android.app.Activity;
import android.widget.TextView;
import android.os.Bundle;
public class Android2 extends Activity
{
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
/* Create a TextView and set its text to "Hello world" */
TextView tv = new TextView(this);
tv.setText("Hello World!");
setContentView(tv);
}
}
There is no problem with your code or imports...
I know it is hard work and a serious change when it comes to shortcuts, menus, overview, etc., but i would suggest to use android studio instead of visual studio if you only write android apps in java. I used visual studio too and switched to android studio.
Android Studio will give you more comfort than every other ide in programming android apps in java!
I know this problems you wrote about very well and had the same. Sry that this isnt a really answer of your problem and does not solves your concrete problem.
Tips for solving, you probably already know:
reboot your pc and visual studio if you not already did
delete caches or other from visual studio
rebuilt/clean your project
not easy, but reinstall visual studio
I hope i could help anyway!

How do I open GPS settings in android?

I am trying to navigate to the geolocation settings page, however, I get an error "ACTION_LOCATION_SOURCE_SETTINGS cannot be resolved or is not a field" in my code. I have searched everywhere, but couldn't find anything different from what I have done already.-
startActivityForResult(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS), 1);
I am running Android 7.0. Is there any other way to do this on my android version?
I think you are using wrong import
Use the below import and remove the previous one
import android.provider.Settings;
Or you can also try like below.
Intent settingintent= new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(settingintent);

Buildozer compiles apk, but it crashes on android

I am able to build an .apk, but after I install it on my android phone it simply crashes at startup. My thoughts for failing is that I am using 3rd party libraries e.g(beautifulsoup).
This is how my imports look in main.py:
from kivy.app import App
from kivy.properties import ListProperty, StringProperty
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.scrollview import ScrollView
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
import time, os, random, urllib2, re, cookielib as cj
from bs4 import BeautifulSoup as bs
from functools import partial
I'm running mavericks 10.9.3
Does it have something to do with buildozer.spec file?
I've tried adding BeautifulSoup to app requirements, but it doesn't change a thing.
Any help would be appreciated.
I ran into this problem as well, but I was (apparently) able to get everything working fine with a workaround. Since it doesn't look like you posted a logcat, I'll assume you ran into the same issue I did.
Yes, you do need to list beautifulsoup4 as a requirement in your spec. From looking into bs4's code, it looks like bs4 is willing to use any of several "builders." It supports HTMLParser, html5lib, or lxml. I have no idea why we can't load HTMLParser, but it's actually the least preferred library of the three, and if it weren't for the fact that there's no try block around the import, it seems that everything would work fine (as long as one of the other parsing libraries was available).
With this in mind, I included one of the other libraries, and I decided to hack the import process so that Python would pretend _htmlparser loaded okay :)
This article was instructive: http://xion.org.pl/2012/05/06/hacking-python-imports/
The end result was something like this:
import imp
import sys
class ImportBlocker(object):
def __init__(self, *args):
self.black_list = args
def find_module(self, name, path=None):
if name in self.black_list:
return self
return None
def load_module(self, name):
module = imp.new_module(name)
module.__all__ = [] # Necessary because of how bs4 inspects the module
return module
sys.meta_path = [ImportBlocker('bs4.builder._htmlparser')]
from bs4 import BeautifulSoup
I also added html5lib to the requirements in buildozer.spec.
Now, is this the right way to solve the problem? I don't know. The best approach would probably be to request that the author fix it. It might be as simple as to put the import in a try block. Nevertheless, this is the approach I've gone with for the moment, and it is at least an interesting exercise, and a way to test your app until a better fix comes along.
Additionally, I should warn you that I only did this recently, so I can't 100% guarantee that it won't cause any problems, but at a minimum, it's worked well enough to get my app running and scraping the particular website I was interested in. Good luck!
I understand that this question is some years old. I think the answer #Will gave was fantastic but unfortunately, in my case, I couldn't use it because html5lib was too slow for what I was making. So this is for reference; for anyone who absolutely must use the built-in parser. It's not pretty but it's fairly manageable.
The issue
After much investigation, I nailed down the cause of the problem. In the buildozer log, I noticed that there was a problem compiling the _htmlparser file with the log reading as follows (with my project path replaced with <project-path>):
Compiling <project-path>/.buildozer/android/platform/build/dists/mypackage/private/lib/python2.7/site-packages/bs4/builder/_htmlparser.py ...
SyntaxError: ("(unicode error) \\N escapes not supported (can't load unicodedata module)", ('<project-path>/.buildozer/android/platform/build/dists/mypackage/private/lib/python2.7/site-packages/bs4/builder/_htmlparser.py', 135, None, 'data = u"\\N{REPLACEMENT CHARACTER}"\n'))
Because it was failing to compile, it wasn't being included in the built apk file. So I looked at the file and at the line that was causing the problem: data = u"\N{REPLACEMENT CHARACTER}" which should actually be replaced by data = u"\ufffd"
Quick-fix
Now the easy way out would be to modify the file right in the package. You could just edit the file mentioned in the error above which should, in theory, work but it's not recommended because every time the package gets re-installed or the code gets built from another machine the problem will be back.
Marginally better fix
It would be nice if the fix was all packaged into our code, so drawing inspiration from #Will's answer, here is the code you would need to put in before your bs4 import:
import sys
class ImportFixer(object):
def __init__(self, mname):
self.mname = mname
def find_module(self, name, path=None):
if name == self.mname:
return self
return None
def load_module(self, name):
import _htmlparser as module
module.__name__ = name
return module
sys.meta_path = [ImportFixer('bs4.builder._htmlparser')]
from bs4 import BeautifulSoup
The main difference is that you need to copy the _htmlparser.py file from the bs4 package to your current directory and fix the before mentioned line data = u"\N{REPLACEMENT CHARACTER}" with data = u"\ufffd"
Then, every time the bs4 module is imported, the import is magically intercepted and the local file is used.
Warning: if you ever update Beautiful Soup, you may need to use a more recent _htmlparser.py file in your project with the same fix made as needed.
Final comment
If I made some typos, grammar mistakes or didn't make sense at all, keep in mind that I worked most of the weekend to fix this and quite frankly I'm not thinking straight. Comment if you have any questions and I'll reply and/or edit my answer when I get a chance.

Phonegap Local Notification Plugin for Android

I'm working on a "Reminders" application on Android using Phonegap[Cordova 2.2].
The user enters a specific date for his reminder and I'm supposed to notify him on time.
I used this plugin to Just show a notification in the status bar & they are working fine.
But I want the notifications to show at specific times. Is there some method to do it ?
I found this plugin that's supposed to do what I want but it's not working, it shows errors at :
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
The import com.phonegap.api.Plugin cannot be resolved
So, how can I fix this error ? I know it might be easy, but I never made native Android Apps before so I'm kind of confused.
Thanks
Looks like a difference between 2.0.0 and 2.2.0, and like the plugin needs updating.
import org.apache.cordova.api.CordovaPlugin;
import org.apache.cordova.api.PluginResult;
This should give you a jumping off point:
http://docs.phonegap.com/en/2.2.0/guide_plugin-development_android_index.md.html#Developing%20a%20Plugin%20on%20Android
For the new Phonegap Release you must also change some stuff:
The LocalNotification class must "extends CordovaPlugin" now
Import classes like eomer says
The execute method of LocalNotification.java must return a boolean now
Change all return arguments that are affected (from PluginResult) to boolean of your choice
Get the context in a new way ctx = this.cordova.getActivity(); and give it the ...AlarmHelper(ctx)

Categories

Resources