MySQL -- Problems running table script - Raspberry Pi Q&A, Help & Troubleshooting

Running Raspian jessie. Working on getting a MySQL database setup to create a time clock solution for a school project. I've got users set up and database created but i'm having trouble using the source command to run a .sql script to create 3 tables.
I'm following a tutorial on instructables, and this sql script file was provided. I can't post the link because I'm new to the forum.
I'm trying to use themysql> \. /attendance/mysql.sql and it says error
This is the contents of the mysql.sql
CREATE TABLE IF NOT EXISTS `cards` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`userId` int(10) unsigned NOT NULL,
`tagId` bigint(18) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
CREATE TABLE IF NOT EXISTS `readings` (
`id` bigint(11) unsigned NOT NULL AUTO_INCREMENT,
`tagId` bigint(18) unsigned NOT NULL,
`time` bigint(14) unsigned NOT NULL,
`action` int(2) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
CREATE TABLE IF NOT EXISTS `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
`surname` varchar(255) COLLATE utf8_czech_ci NOT NULL,
`active` enum('0','1') COLLATE utf8_czech_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
Any input is much appreciated.

Related

[Q] How to enable WifiAP / tethering programmatically from within app on SGS I9000?

I try to activate WifiAP (wifi tethering) via my application code. Since there is no direct API for it, it needs to be done via reflection.
Using the approach as mentioned on StackOverflow.com.
It works fine on Nexus One, HTC Desire, Huawei Ideos (all running 2.2.x), but it doesn't run on the SGS with 2.2.1.
Checking the android.net.wifi.WifiManager class via reflection, I see that Samsung has obviously modified the class and it has 57 instead of 37 methods.
Unfortunately the modified WifiManager class is not open sourced by Samsung and the error messages don't give any details or stack trace.
I am looking for somebody who can enable WifiAP activation programmatically on the SGS, eventually by modifying the underlying system, since I'm myself am an application developer, not working on system level. Also considering contract work!
There are two things I am trying:
1) activate WifiAP directly via reflection:
Code:
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
Method[] wmMethods = wifi.getClass().getDeclaredMethods();
Log.d(TAG, "enableMobileAP methods " + wmMethods.length);
for(Method method: wmMethods){
Log.d(TAG, "enableMobileAP method.getName() " + method.getName());
if(method.getName().equals("setWifiApEnabled")) {
WifiConfiguration netConfig = new WifiConfiguration();
netConfig.SSID = "MyWifiAP";
netConfig.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
netConfig.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
netConfig.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
netConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
try {
Log.d(TAG, "enableMobileAP try: ");
method.invoke(wifi, netConfig, enabled);
if (netConfig.wepKeys!=null && netConfig.wepKeys.length>=1)
Log.d(TAG, "enableMobileAP key : " + netConfig.wepKeys[0]);
Log.d(TAG, "enableMobileAP enabled: ");
mIsWifiEnabled = enabled;
} catch (Exception e) {
Log.e(TAG, "enableMobileAP failed: ", e);
}
}
}
Attached are the logfiles I am getting on Nexus One (success) and SGS (failure).
The noticable part in the SGS log are maybe these lines:
Code:
D/WifiService( 2818): setWifiApEnabled: allowWifiAp: true
E/WifiService( 2818): setWifiApEnabledState 2
E/SoftapController( 2681): Softap already stopped
E/WifiService( 2818): Exception in stopAccessPoint()
E/WifiService( 2818): setWifiApEnabledState 4
D/WifiAp (23523): enableMobileAP key : null
2) another thing I try - since the modified SGS WifiManager (only that one) has a method named 'showApDialog' without any parameter taken, I try to call that method, but this also just gives an 'Error' in the log without further explanation.)
Code:
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
Method[] wmMethods = wifi.getClass().getDeclaredMethods();
Log.d(TAG, "enableMobileAP methods " + wmMethods.length);
for(Method method: wmMethods){
Log.d(TAG, "enableMobileAP method.getName() " + method.getName());
if(method.getName().equals("showApDialog")) {
WifiConfiguration netConfig = new WifiConfiguration();
try {
method.invoke(wifi);
} catch (Exception e) {
Log.e("Main", "Can't open ap dialog.", e);
}
}
}
I have been able to enable an existing configuration by passing null as the WifiConfiguration parameter to the setWifiApEnabled method.
I had the same problems as you when I tried to use this function to create a new configuration. I also failed when I tried to pass the existing configuration as a parameter, after invoking getWifiApConfiguration.
I noticed in the Android source code that there is a similar function called setWifiApConfiguration, but calling wifiManager.getClass().getMethod("setWifiApConfiguration") throws NoSuchMethodException when I run it on my SGS.
I also wondered if I can use addNetwork to create a new configuration, but suspect it is only for connecting to APs, rather than creating one.
As I only wanted to toggle the existing configuration, which I have now achieved, I stopped investigating at this point.
Hope that helps,
Good luck...
Yes, I've also got it to work meanwhile but didn't update this thread. You're right, the problem were the configuration, which had to be left empty. Cheers
thank you for sharing this, it really made my day
it seems that (on Android 2.3.4) it only works if you first disable the WiFi (Nexus One).

Fatal Error, null object. How to debug?

I have inported an Eclipse app into Studio. When I run the app I get the fatal error:
Attempt to invoke virtual method 'void android.nfc.NfcAdapter.enableForegroundDispatch(android.app.Activity, android.app.PendingIntent, android.content.IntentFilter[ ], java.lang.String[ ][ ])' on a null object reference
As far as I can tell the error is caused by the mAdapter.enableForegroundDispatch method below, because one ore more of it's parameters is null. I put a breakpoint there and run the debugger in the emulator. It never hits the breakpoint. I also set the debugger to break on any exception and it doesn't. the App starts and I get the "unfortunately the app has stopped" message.
@override
protected void onResume()
{
// TODO Auto-generated method stub
super.onResume();
//Used for DEBUG : Log.v("NFCappsActivity.java", "ON RESUME NFC APPS ACTIVITY");
mPendingIntent = PendingIntent.getActivity(this, 0,new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
mAdapter.enableForegroundDispatch(this, mPendingIntent, mFilters, mTechLists);
}
Thanks for the help.
Rich

Can't get MAC address

Currently I can get it to work if I use:
private static String address = "00:00:00:25:02:80";
BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
But I want to be able to use:
Intent intent = getIntent();
newAddress = intent.getStringExtra(DeviceListActivity.EXTRA_DEVICE_ADDRESS);
BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(newAddress);
So I've seen this code in other examples but It doesn't work on mine?
I have also tried other methods.
String newAddress = mBluetoothAdapter.getAddress();
This also doesn't work.
So can anybody help me with this I want to get the MAC address on it's own to connected device without declaring it.
Hello,
Check here.
Have you inserted the permission in the manifest? (android.permission.BLUETOOTH)
What does mBluetoothAdapter.getAddress() return for you?
Check also here for the remote device's MAC.

Android Studios, Update on time

Hey, I'm fairly new to using android studios and I am trying to make an app that updates its display every few seconds.
The method I am currently using is to update when a button is pressed using the following:
public void Refreshing(View view) {
// do stuff here...
}
Where Refreshing is the onClick of a button I placed.
How can I use a similar format but instead of doing things on a button press just have it done automatically after a few seconds?
You can use a android.os.Handler for that. It allows you to interact with the event loop and post a Runnable that will be executed after a given delay
In your Activity's onCreate() method:
Code:
final int delayMs = 1000;
final Handler handler = new Handler(this);
final Runnable runnable = new Runnable() {
@Override public void run() {
// Call your refresh method
Refreshing();
// Restart the timer
handler.postDelayed(runnable, delayMs);
};
}
handler.postDelayed(runnable, delayMs);
Thanks, this is exactly what I'm looking for. I add the code to the onCreate but I had an semicolon error. So I added another semicolon but its having trouble with a few other parts. Here is what I have.
Code:
final int delayMs = 1000;
final Handler handler = new Handler([B]this[/B]);
final Runnable runnable = new Runnable() {
@Override public void run() {
// Call your refresh method
Refreshing();
// Restart the timer
handler.postDelayed([B]runnable[/B], delayMs);
};
};
handler.postDelayed(runnable, delayMs);
The error listed is:
Error : (134, 33) error: no suitable constructor found for Handler(MainActivity)
constructor Handler.Handler(Looper,Callback) is not applicable
(actual and formal argument lists differ in length)
constructor Handler.Handler(Looper) is not applicable
(actual argument MainActivity cannot be converted to Looper by method invocation conversion)
constructor Handler.Handler(Callback) is not applicable
(actual argument MainActivity cannot be converted to Callback by method invocation conversion)
constructor Handler.Handler() is not applicable
(actual and formal argument lists differ in length)
The words I bolded are underlined in red in Android Studios.
this ----------------has a constructor error
runnable ----------has a initialization error
I tried troubleshooting for a little bit and took out the this and the only error left is with runnable. It says: Error: (141, 37) error: variable runnable might not have been initialized
Yep, I wrote the code without testing it. It might need some adaptation.
Here is a version that should work:
Code:
final int delayMs = 1000;
final Handler handler = new Handler([B]this[/B]);
final Runnable runnable = new Runnable() {
@Override public void run() {
// Call your refresh method
Refreshing();
// Restart the timer
handler.postDelayed([B]this[/B], delayMs);
};
};
handler.postDelayed([B]runnable[/B], delayMs);
Thank you so much, it worked. I just had to change
Code:
final Handler handler = new Handler(this);
to
Code:
final Handler handler = new Handler();

[Help][Q] Compiling Magisk from source errors

UPDATE: ISSUE HAS BEEN FIXED, THANK YOU
Hi all,
I am trying to compile Magisk after cloning it from the Github repository (https://github.com/topjohnwu/Magisk).
I cloned it via
Code:
git clone [B]-recursive[/B] https://github.com/topjohnwu/Magisk.git
in order to download the proper submodules as well.
After running
Code:
python3 build.py all 14.3 143
(btw, I am simply guessing the versioncode argument. Does it matter?)
the error I get is the following:
pastebin: https://pastebin.com/eVwGhvXa
Code:
* Building Magisk binaries
[x86] Compile : b64xz <= b64xz.c
[x86] Compile : magisk <= magisk.c
[x86] Compile : magisk <= daemon.c
[x86] Compile : magisk <= socket_trans.c
[x86] Compile : magisk <= log_monitor.c
[x86] Compile : magisk <= bootstages.c
[x86] Compile : magisk <= misc.c
[x86] Compile : magisk <= vector.c
[x86] Compile : magisk <= xwrap.c
[x86] Compile : magisk <= list.c
[x86] Compile : magisk <= img.c
[x86] Compile : magisk <= file.c
[x86] Compile : magisk <= magiskhide.c
[x86] Compile : magisk <= proc_monitor.c
[x86] Compile : magisk <= hide_utils.c
[x86] Compile : magisk <= magiskpolicy.c
[x86] Compile : magisk <= rules.c
[x86] Compile : magisk <= sepolicy.c
[x86] Compile : magisk <= api.c
[x86] Compile++ : magisk <= resetprop.cpp
[x86] Compile++ : magisk <= system_properties.cpp
In file included from jni/resetprop/resetprop.cpp:63:
In file included from jni/resetprop/_system_properties.h:40:
jni/resetprop/system_properties.h:46:64: error: expected function body after function declarator
int __system_property_set2(const char* key, const char* value) __INTRODUCED_IN(12);
^
jni/resetprop/system_properties.h:61:19: error: expected function body after function declarator
void* cookie) __INTRODUCED_IN(26);
^
jni/resetprop/system_properties.h:70:3: error: expected function body after function declarator
__INTRODUCED_IN(19);
^
jni/resetprop/system_properties.h:89:5: error: expected function body after function declarator
__INTRODUCED_IN(26);
^
jni/resetprop/resetprop.cpp:177:3: error: use of undeclared identifier '__system_property_read_callback2'; did you mean
'__system_property_read2'?
__system_property_read_callback2(pi, read_prop_info, value);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__system_property_read2
jni/resetprop/system_properties.h:94:5: note: '__system_property_read2' declared here
int __system_property_read2(const prop_info* pi, char* name, char* value);
^
jni/resetprop/resetprop.cpp:177:40: error: cannot initialize a parameter of type 'char *' with an lvalue of type 'void (void *, const
char *, const char *, uint32_t)' (aka 'void (void *, const char *, const char *, unsigned int)')
__system_property_read_callback2(pi, read_prop_info, value);
^~~~~~~~~~~~~~
jni/resetprop/system_properties.h:94:56: note: passing argument to parameter 'name' here
int __system_property_read2(const prop_info* pi, char* name, char* value);
^
jni/resetprop/resetprop.cpp:192:2: error: use of undeclared identifier '__system_property_read_callback2'; did you mean
'__system_property_read2'?
__system_property_read_callback2(pi, cb_wrapper, cookie);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__system_property_read2
jni/resetprop/system_properties.h:94:5: note: '__system_property_read2' declared here
int __system_property_read2(const prop_info* pi, char* name, char* value);
^
jni/resetprop/resetprop.cpp:192:39: error: cannot initialize a parameter of type 'char *' with an lvalue of type 'void (void *, const
char *, const char *, uint32_t)' (aka 'void (void *, const char *, const char *, unsigned int)')
__system_property_read_callback2(pi, cb_wrapper, cookie);
^~~~~~~~~~
jni/resetprop/system_properties.h:94:56: note: passing argument to parameter 'name' here
int __system_property_read2(const prop_info* pi, char* name, char* value);
^
In file included from jni/resetprop/system_properties.cpp:54:
In file included from jni/resetprop/_system_properties.h:40:
jni/resetprop/system_properties.h:46:64: error: expected function body after function declarator
int __system_property_set2(const char* key, const char* value) __INTRODUCED_IN(12);
^
jni/resetprop/system_properties.h:61:19: error: expected function body after function declarator
void* cookie) __INTRODUCED_IN(26);
^
jni/resetprop/system_properties.h:70:3: error: expected function body after function declarator
__INTRODUCED_IN(19);
^
jni/resetprop/system_properties.h:89:5: error: expected function body after function declarator
__INTRODUCED_IN(26);
^
jni/resetprop/resetprop.cpp:254:2: error: use of undeclared identifier '__system_property_foreach2'; did you mean
'__system_property_get2'?
__system_property_foreach2(prop_foreach_cb, &wrap);
^~~~~~~~~~~~~~~~~~~~~~~~~~
__system_property_get2
jni/resetprop/system_properties.h:96:5: note: '__system_property_get2' declared here
int __system_property_get2(const char* name, char* value);
^
jni/resetprop/resetprop.cpp:254:29: error: cannot initialize a parameter of type 'const char *' with an lvalue of type
'void (const prop_info *, void *)'
__system_property_foreach2(prop_foreach_cb, &wrap);
^~~~~~~~~~~~~~~
jni/resetprop/system_properties.h:96:40: note: passing argument to parameter 'name' here
int __system_property_get2(const char* name, char* value);
^
jni/resetprop/resetprop.cpp:271:10: error: use of undeclared identifier '__system_property_set2'; did you mean
'__system_property_get2'?
ret = __system_property_set2(name, value);
^~~~~~~~~~~~~~~~~~~~~~
__system_property_get2
jni/resetprop/system_properties.h:96:5: note: '__system_property_get2' declared herejni/resetprop/system_properties.cpp:97:3: error: unknown type name 'va_list'; did you mean '__va_list'?
va_list vl;
^~~~~~~
__va_list
/home/solar/Android/Sdk/ndk-bundle/platforms/android-21/arch-x86/usr/include/sys/types.h:129:27: note: '__va_list' declared here
int __system_property_get2(const char* name, char* value);
^
typedef __builtin_va_list __va_list;
^
jni/resetprop/resetprop.cpp:271:39: error: cannot initialize a parameter of type 'char *' with an lvalue of type 'const char *'
ret = __system_property_set2(name, value);
^~~~~
jni/resetprop/system_properties.h:96:52: note: passing argument to parameter 'value' here
int __system_property_get2(const char* name, char* value);
^
jni/resetprop/system_properties.cpp:98:3: error: use of undeclared identifier 'va_start'
va_start(vl, format);
^
jni/resetprop/system_properties.cpp:99:13: error: use of undeclared identifier 'vsnprintf'
int ret = vsnprintf(s, n, format, vl);
^
jni/resetprop/system_properties.cpp:100:3: error: use of undeclared identifier 'va_end'
va_end(vl);
^
jni/resetprop/resetprop.cpp:278:10: error: use of undeclared identifier '__system_property_set2'; did you mean
'__system_property_get2'?
ret = __system_property_set2(name, value);
^~~~~~~~~~~~~~~~~~~~~~
__system_property_get2
jni/resetprop/system_properties.h:96:5: note: '__system_property_get2' declared here
int __system_property_get2(const char* name, char* value);
^
jni/resetprop/resetprop.cpp:278:39: error: cannot initialize a parameter of type 'char *' with an lvalue of type 'const char *'
ret = __system_property_set2(name, value);
^~~~~
jni/resetprop/system_properties.h:96:52: note: passing argument to parameter 'value' here
int __system_property_get2(const char* name, char* value);
^
14 errors generated.
make: *** [obj/local/x86/objs/magisk/resetprop/resetprop.o] Error 1
make: *** Waiting for unfinished jobs....
jni/resetprop/system_properties.cpp:1012:3: error: unknown type name 'va_list'; did you mean '__va_list'?
va_list ap;
^~~~~~~
__va_list
/home/solar/Android/Sdk/ndk-bundle/platforms/android-21/arch-x86/usr/include/sys/types.h:129:27: note: '__va_list' declared here
typedef __builtin_va_list __va_list;
^
jni/resetprop/system_properties.cpp:1030:3: error: use of undeclared identifier 'va_start'
va_start(ap, num_args);
^
jni/resetprop/system_properties.cpp:1034:33: error: expected '(' for function-style cast or type construction
spec_entry = va_arg(ap, char**);
~~~~^
jni/resetprop/system_properties.cpp:1034:35: error: expected expression
spec_entry = va_arg(ap, char**);
^
jni/resetprop/system_properties.cpp:1037:7: error: use of undeclared identifier 'va_end'
va_end(ap);
^
jni/resetprop/system_properties.cpp:1043:7: error: use of undeclared identifier 'va_end'
va_end(ap);
^
jni/resetprop/system_properties.cpp:1048:3: error: use of undeclared identifier 'va_end'
va_end(ap);
^
jni/resetprop/system_properties.cpp:1053:3: error: unknown type name 'FILE'
FILE* file = fopen(filename, "re");
^
jni/resetprop/system_properties.cpp:1053:16: error: use of undeclared identifier 'fopen'; did you mean 'open'?
FILE* file = fopen(filename, "re");
^~~~~
open
/home/solar/Android/Sdk/ndk-bundle/platforms/android-21/arch-x86/usr/include/fcntl.h:73:12: note: 'open' declared here
extern int open(const char*, int, ...);
^
jni/resetprop/system_properties.cpp:1053:32: error: cannot initialize a parameter of type 'int' with an lvalue of type
'const char [3]'
FILE* file = fopen(filename, "re");
^~~~
/home/solar/Android/Sdk/ndk-bundle/platforms/android-21/arch-x86/usr/include/fcntl.h:73:33: note: passing argument to parameter here
extern int open(const char*, int, ...);
^
jni/resetprop/system_properties.cpp:1497:3: error: use of undeclared identifier '__system_property_wait2'; did you mean
'__system_property_add2'?
__system_property_wait2(nullptr, old_serial, &new_serial, nullptr);
^~~~~~~~~~~~~~~~~~~~~~~
__system_property_add2
jni/resetprop/system_properties.cpp:1449:5: note: '__system_property_add2' declared here
int __system_property_add2(const char* name, unsigned int namelen, const char* value,
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [obj/local/x86/objs/magisk/resetprop/system_properties.o] Error 1
Build Magisk binary failed!
I'm building on Ubuntu 16.04 Xenial 64 bits.
It seems like the cmake or C libraries I have are older or not compatible with the one required by Magisk.
I'm out of ideas and I can't find any tutorials on compiling Magisk or any info on the errors above via Google.
Could you please help me out with some tips on what am I missing? I'd really appreciate it.
Thank you.
@easytotype Have you made sure that you're using the latest Android NDK?
Also, have you tried "sudo apt-get update && sudo apt-get upgrade"?
And, versionString and versionCode should be 14.4 and 1440, instead of 14.3 and 143 (it isn't related to this error, though)
Sent from my Samsung Galaxy Trend Plus using XDA Labs
DodoGTA said:
@easytotype Have you made sure that you're using the latest Android NDK? (...)
Click to expand...
Click to collapse
ndk was the problem indeed!
I had NDK v14,
installing the latest v15 solved the issue.
The facepalm was huge, but without your help I would have been for stuck much much longer.
Thank you very much @DodoGTA :good::good::good::good::good:

Categories

Resources