Compile ReactAndroid, fbjni error - github

Downloaded from GitHub, to make moudle 'ReactAndroid', then:
Error:(687) Android NDK: Module reactnativejnifb depends on undefined modules: fbjni
Error:(700) *** Android NDK: Aborting (set APP_ALLOW_MISSING_DEPS=true to allow missing dependencies)
Error:Execution failed for task ':ReactAndroid:buildReactNdkLib'.
Process 'command '/Users/sumomokawaakira/Downloads/adt-bundle-mac-x86_64/sdk/ndk-bundle/ndk-build'' finished with non-zero exit value 2

I had this problem too. I think you can fix it by making sure you are using the precisely correct version of the Android NDK (android-ndk-r10e).
Also make sure that you set the environment variables and stuff done right.
(For what it's worth I'm stuck on later steps, but hopefully this should help you get passed this particular issue)

You have to change your path to ANDROID_NDK to run gradle command locally.
export ANDROID_NDK=/Users/your_unix_name/android-ndk/android-ndk-r10e
In my case, I put NDK file at /Users/tomo/temp/android-ndk-r10e
so
export ANDROID_NDK=/Users/tomo/temp/android-ndk-r10e
Or if you do not want to change ANDROID_NDK, you can update ReactAndroid/build.gradle
def findNdkBuildFullPath() {
// we allow to provide full path to ndk-build tool
if (hasProperty('ndk.command')) {
return property('ndk.command')
}
// or just a path to the containing directory
if (hasProperty('ndk.dir')) {
def ndkDir = property('ndk.dir')
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
}
// ** Add below. should be before if (System.getenv('ANDROID_NDK') clause **
Properties properties = new Properties()
properties.load(project.rootProject.file('ReactAndroid/local.properties').newDataInputStream())
if (properties.hasProperty('ndk.dir')) {
def ndkDir = properties.getProperty('ndk.dir')
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
}
if (System.getenv('ANDROID_NDK') != null) {
def ndkDir = System.getenv('ANDROID_NDK')
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
}
def ndkDir = android.hasProperty('plugin') ? android.plugin.ndkFolder :
plugins.getPlugin('com.android.library').hasProperty('sdkHandler') ?
plugins.getPlugin('com.android.library').sdkHandler.getNdkFolder() :
android.ndkDirectory.absolutePath
if (ndkDir) {
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
}
return null
}
then update ReactAndroid/local.properties
ndk.dir=/Users/tomo/temp/android-ndk-r10e
sdk.dir=/Applications/sdk
and Run app from Android Studio

for React Native 7.0
try either :
rm -rf node_modules && yarn install (worked for me)
or
These steps:
Close Android Studio
Add android.disableAutomaticComponentCreation=true in android/gradle.properties
Reopen project and build.

Related

NuGet package restore in Roslyn analyzer test

In my unit tests for my Roslyn analyzer, I need to use Microsoft.AspNetCore.Mvc in the test code string. I believe that means I need the long form of testing, so I did the following.
var expected = VerifyCS.Diagnostic(MyAnalyzer.DiagnosticId)
.WithLocation(0)
.WithArguments("Method");
var assemblies = ReferenceAssemblies
.Default
.AddPackages(ImmutableArray.Create(new PackageIdentity("Microsoft.AspNetCore.Mvc.Core", "6.0.0.0")));
await new VerifyCS.Test {
ReferenceAssemblies = assemblies,
TestState = {
Sources = {
test
},
ExpectedDiagnostics = {
expected
}
}
}.RunAsync();
When running the test, it tells me:
Unable to find package 'Microsoft.AspNetCore.Mvc.Core'. Existing packages must be restored before performing an install or update.
I'm not sure how to resolve that in the unit test.

KMM, after involving XCTest, get build error "Building for iOS Simulator, but linking in dylib built for iOS..."

I did an experiment to add iOS UI test to project that was created with Kotlin Multiplatform Mobile(KMM). By start to follow the official guide, I was able to connect shared library in Xcode and launch the iOS app or perform a Unit test from Android Studio. But when I try to involve XCTest to add a few UI test, the Xcode complaint as below screenshot.
I have searched out the internet a lot, still without luck. Guys, if you are face the same issue before, please give me some hint about how to tracking down this arch problem.
From the build log error, I think first Gradle Task :shared:linkDebugFrameworkIosSimulatorArm64 FAILED and below it said XCTest is built for iOS arm64 arch, which is not aligned with iOS Simulator.
I'm using a Mac M1 machine, it could be the reason. So I switch Xcode to Rosetta mode, this time command embedAndSignAppleFrameworkForXcode which is from Run Script has NO-SOURCE and followed one iOS Simulator version alignment complain.
XCTest.def
language = Objective-C
package = platform.XCTest
depends = UIKit
modules = XCTest
linkerOpts= -weak_framework XCTest -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/UIKit.framework -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks/
compilerOpts= -weak_framework XCTest -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks/
build.gradle file
import com.android.build.gradle.internal.scope.ProjectInfo.Companion.getBaseName
plugins {
kotlin("multiplatform")
id("com.android.library")
}
kotlin {
android {
}
listOf(
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "shared"
embedBitcode = org.jetbrains.kotlin.gradle.plugin.mpp.Framework.BitcodeEmbeddingMode.DISABLE
}
it.compilations.getByName("main") {
val xctest by cinterops.creating {
// Def-file describing the native API.
defFile(project.file("src/iosMain/xctest.def"))
}
}
}
sourceSets {
val commonMain by getting {
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
// implementation(
// "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.5-native-mt"
// )
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val androidMain by getting {
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.5-native-mt")
implementation("androidx.test.espresso:espresso-core:3.2.0")
implementation("androidx.test.espresso:espresso-contrib:3.2.0")
implementation("androidx.test:core:1.4.0")
implementation("androidx.test.ext:junit:1.1.3")
implementation("androidx.test.uiautomator:uiautomator:2.2.0")
}
}
val androidTest by getting {
dependencies {
}
}
val iosArm64Main by getting
val iosSimulatorArm64Main by getting
val iosMain by creating {
dependsOn(commonMain)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
}
val iosArm64Test by getting
val iosSimulatorArm64Test by getting
val iosTest by creating {
dependsOn(commonTest)
iosArm64Test.dependsOn(this)
iosSimulatorArm64Test.dependsOn(this)
}
}
}
android {
namespace = "com.bsc.radiant_hope_test"
compileSdk = 32
defaultConfig {
minSdk = 21
targetSdk = 32
}
}
Shared library is connected.
You don't need to use Rosetta in this case
As I see in your XCTest.def file, you are trying to link all binaries created with Kotlin tooling with only iPhoneOS.platform which doesn't contain needed parts for running simulator.
Please try to add the following lines to your XCTest.def file
#Linker options for devices
linkerOpts.ios_arm64 = -weak_framework XCTest -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/UIKit.framework -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks/
#Linker options for simulators
linkerOpts.ios_x64 = -weak_framework XCTest -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/UIKit.framework -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks/
linkerOpts.ios_simulator_arm64 = -weak_framework XCTest -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/UIKit.framework -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks/

Try-catch problem in Embarcadero C++ 10.1 x64

I have a problem executing 64-bit version of my program:
_XMLDoc = new TBasicXML(_owner);
try {
_XMLDoc->LoadFromFile(_filePath);
}
catch (...) {
delete _XMLDoc;
return "?";
}
In 32-bit version, when _filePath does not exist, program goes into catch block,
but in 64-bit version it does not.
Actually, it throws EDOMParseError several times and it enters catch block after I press continue for each error dialog.
TBasicXML class constructor is:
__fastcall TBasicXML::TBasicXML(TComponent *Owner, UnicodeString encoding)
{
_doc = new TXMLDocument(Owner);
_doc->Active = true;
_doc->Encoding = encoding;
_doc->Options = TXMLDocOptions()<<doNodeAutoIndent;
}
Is there something specifically I need to specify in project options for Win 64 target that defers from 32-bit target, to avoid such behavior?
Edit: I was focused on this part of code (parser), because it's executed at the program start. However, I've added this peace of code in my main form's constructor, before parser call:
int x;
try {
x = StrToInt("not a number");
}
catch (...) {
MessageDlg("Exception catched!", mtInformation, TMsgDlgButtons() << mbOK, 0);
}
I've built 64-bit release version and started the program (Run without debugger). It simply aborts without any message. When the same program (release) is started with debugger (Run (F9)) it shows error message dialog (EConverterError) and then after continue is pressed it shows my MessageDlg.
Note: with 32-bit version, there is no problem at all.
Edit2: I've test some other projects, the same situation:
__fastcall TfrmMain::TfrmMain(TComponent* Owner)
: TForm(Owner)
{
// test
int x;
try {
x = StrToInt("not a number");
}
catch (...) {
MessageDlg("Exception catched!", mtInformation, TMsgDlgButtons() << mbOK, 0);
}
//Ie settings
IEGlobalSettings()->AutoFragmentBitmap = false;
IEGlobalSettings()->MsgLanguage = msEnglish;
IEGlobalSettings()->EnableTheming = true;
// initialize spengine
speInit(); // delayed DLL load
FLeftId = 0;
FRightId = 0;
}
Again, 64-bit release version, when started from IDE, without debugger, silently terminates program, when started with debugger, works normally.
Edit3: Now, here is a mystery?
From the example above, I've excluded DLL library (spEngine.a) from build and commented all code related to DLL entry calls and try-catch block works as usual. When spEngine.a is included, no matter if DLL loading (spEngine.dll) is delayed or not and without any call to DLL entries, try-catch block woks as previously described. Very strange. spEngine.dll calls custom Intel's ipp DLL build with MVSC2017. The similar try-catch behavior I have experienced with another library that calls OpenCV DLLs (wrapper built with MSVC2017). The complete source code is here: https://github.com/spetric/Lips
Note: 64-bit host application works well, no problems with functionality, only with strange try-catch block behavior.

Unity 2018.1 WebGL fails on CommitUpdate using icsharpcode.sharpziplib

I have been working on a WebGL project using Unity 2017. We use ICSharpCode.SharpZipLib.Zip to generate zip-files and upload them to our server. This worked well using the following code:
public string ZipFiles(List<string> files)
{
// create new zip file
string zipPath = Application.persistentDataPath + "/upload.zip";
try
{
// prepare
FileStream fsOut = File.Create(zipPath);
ZipFile zip = ZipFile.Create(fsOut);
// fill
zip.BeginUpdate();
foreach (string file in files)
{
zip.Add(file, Path.GetFileName(file));
}
Debug.Log("Zip before commit");
zip.CommitUpdate();
Debug.Log("Zip after commit");
zip.Close();
Debug.Log("Zip after close");
fsOut.Close();
Debug.Log("Zip filestream closed");
}
catch (Exception ex)
{
Debug.Log("Exception Zip: " + ex);
}
// finish
return zipPath;
}
Now with the update to Unity 2018.1 we also updated to .Net 4.6 - everything is working fine in Editor.
Using the WebGL build the application fails on zip.CommitUpdate();
Error Log only displays:
NotSupportedException: Encoding 437 data could not be found. Make sure you have correct international codeset assembly installed and enabled.
at System.Text.Encoding.GetEncoding (System.Int32 codepage) [0x00000] in <00000000000000000000000000000000>:0
(Filename: currently not available on il2cpp Line: -1)
I think this a very useless error log...
The zip-file in the file-system gets uploaded, but is empty. Files are available: one xml and two json files. (Already made a check with File.exists earlier...)
Can anyone help? Thanks!
In the .NET 4.6 class libraries, it might be the case that encoding 437 is in an embedded resource. By default WebGL builds do not include embedded resources to save size. You can enable embedded resources for WebGL like this:
https://forum.unity.com/threads/enabling-embedded-resources-with-webgl.326069/
I'm not certain this is the issue, but it is probably worth a try. If this does not work, it is a bug we should investigate from the Unity side. Please submit a bug report.
Finally figured it out!
I cloned the github project SharpZipLib and created the DLL with .Net Standard 2.0 as ClassLibrary.
I replaced my existing DLL with the self created DLL.
Then I made little changes to the code: before we were using a FileStream to generate the zip-file. Now we use the ZipFile.Create(string path) variant.
Also we use a DiskArchiveStorage refering to the zip-file. ("on disk")
public string ZipFiles(List<string> files)
{
// create new zip file
string zipPath = Application.persistentDataPath + "/upload.zip";
try
{
// prepare
ZipFile zip = ZipFile.Create(zipPath);
// fill
DiskArchiveStorage myDisk = new DiskArchiveStorage(zip);
zip.BeginUpdate(myDisk);
foreach (string file in files)
{
Debug.Log("ZIP: add " + file);
if (!File.Exists(file))
{
Debug.Log("File not found!");
}
zip.Add(file, Path.GetFileName(file));
}
zip.CommitUpdate();
zip.Close();
}
catch (Exception ex)
{
Debug.Log("Exception Zip: " + ex);
}
// finish
return zipPath;
}
Now it is working like before!

Unable to use WURFL with Scala

When I run WURFL demo app for scala:
object Demo {
def main(args: Array[String]) {
// Create WURFL passing a GeneralWURFLEngine object with a wurfl xml
val wurflWrapper = new Wurfl(new GeneralWURFLEngine("classpath:/resources/wurfl.zip"))
// Set cache provider
wurflWrapper.setCacheProvider(new LRUMapCacheProvider)
// Set Performance/Accuracy Mode
wurflWrapper.setTargetAccuracy
// Set Capability Filter
wurflWrapper.setFilter(
"can_assign_phone_number",
"marketing_name",
"brand_name",
"model_name",
"is_smarttv",
"is_wireless_device",
"device_os",
"device_os_version",
"is_tablet",
"ux_full_desktop",
"pointing_method",
"preferred_markup",
"resolution_height",
"resolution_width",
"xhtml_support_level")
// User-Agent here
var userAgent = ""
// Defining headers
var headers = Map("Accept-Datetime"->"Thu, 31 May 2007 20:35:00 GMT")
headers += ("Content-Type"-> "application/x-www-form-urlencoded")
var device = wurflWrapper.deviceForHeaders(userAgent, headers)
val matchType = device.matchType
if (matchType == MatchType.conclusive)
{
println("Match Type is conclusive")
}
val wireless = device.capability("is_wireless_device")
println("Is wireless: " + wireless)
}
}
I get this exception:
[main] ERROR net.sourceforge.wurfl.core.GeneralWURFLEngine - cannot initialize: java.lang.NullPointerException: in is null
java.lang.NullPointerException: in is null
at java.util.zip.ZipInputStream.<init>(ZipInputStream.java:101)
at java.util.zip.ZipInputStream.<init>(ZipInputStream.java:80)
at net.sourceforge.wurfl.core.resource.FileLoader.fromZipFile(FileLoader.java:248)
at net.sourceforge.wurfl.core.resource.FileLoader.openInputStream(FileLoader.java:230)
at net.sourceforge.wurfl.core.resource.FileLoader.getStream(FileLoader.java:288)
at net.sourceforge.wurfl.core.resource.XMLResource.getData(XMLResource.java:163)
at net.sourceforge.wurfl.core.resource.DefaultWURFLModel.init(DefaultWURFLModel.java:115)
at net.sourceforge.wurfl.core.resource.DefaultWURFLModel.<init>(DefaultWURFLModel.java:107)
at net.sourceforge.wurfl.core.GeneralWURFLEngine.init(GeneralWURFLEngine.java:340)
at net.sourceforge.wurfl.core.GeneralWURFLEngine.initIfNeeded(GeneralWURFLEngine.java:319)
at net.sourceforge.wurfl.core.GeneralWURFLEngine.getDeviceForRequest(GeneralWURFLEngine.java:451)
at com.scientiamobile.wurfl.Wurfl.deviceForHeaders(Wurfl.scala:77)
at com.Demo$.main(Demo.scala:49)
at com.Demo.main(Demo.scala)
Exception in thread "main" net.sourceforge.wurfl.core.exc.WURFLRuntimeException: WURFL unexpected exception
at net.sourceforge.wurfl.core.GeneralWURFLEngine.initIfNeeded(GeneralWURFLEngine.java:322)
at net.sourceforge.wurfl.core.GeneralWURFLEngine.getDeviceForRequest(GeneralWURFLEngine.java:451)
at com.scientiamobile.wurfl.Wurfl.deviceForHeaders(Wurfl.scala:77)
at com.Demo$.main(Demo.scala:49)
at com.Demo.main(Demo.scala)
Caused by: java.lang.NullPointerException: in is null
at java.util.zip.ZipInputStream.<init>(ZipInputStream.java:101)
at java.util.zip.ZipInputStream.<init>(ZipInputStream.java:80)
at net.sourceforge.wurfl.core.resource.FileLoader.fromZipFile(FileLoader.java:248)
at net.sourceforge.wurfl.core.resource.FileLoader.openInputStream(FileLoader.java:230)
at net.sourceforge.wurfl.core.resource.FileLoader.getStream(FileLoader.java:288)
at net.sourceforge.wurfl.core.resource.XMLResource.getData(XMLResource.java:163)
at net.sourceforge.wurfl.core.resource.DefaultWURFLModel.init(DefaultWURFLModel.java:115)
at net.sourceforge.wurfl.core.resource.DefaultWURFLModel.<init>(DefaultWURFLModel.java:107)
at net.sourceforge.wurfl.core.GeneralWURFLEngine.init(GeneralWURFLEngine.java:340)
at net.sourceforge.wurfl.core.GeneralWURFLEngine.initIfNeeded(GeneralWURFLEngine.java:319)
... 4 more
The "wurfl.zip" is well located under "resources".
I also tried adding it to main Scala classes path, but still not luck.
From a code perspective
val wurflWrapper = new Wurfl(new GeneralWURFLEngine("classpath:/resources/wurfl.zip"))
is a proper way to initialize your WURFL engine.
You may want to provide information about how you're running the demo, if you are running it inside an IDE (IDEA, Eclipse or Netbeans), or using command line, or other ways. It can also be useful to tell whether you're using Maven or not.
In case you are running it using command line, please provide a sample of how you launch the Scala app and how you set the classpath.
Assuming a scenario where you are compiling with maven and executing the project directly into the target dir using -cp classes, execution will result in your classpath error because resource files are not included in the classes directory.
Make sure that wurfl-scala-example-.jar is included your classpath.
If you are using the Demo project inside IntelliJ IDEA, please make sure that the resource directory is marked as "resource", otherwise IDEA run tool will not include the wurfl.zip file as a resource.
Hope this helps.