Didn't find class org.cocos2dx.cpp.AppActivity - cocos2d-x

Cocos2d-x version 3 problems running Android test application.
I've followed the instructions how to create a new project using the cocos.py script.
This works fine. Then I follow the instructions running build_native.py. Import the Android test application to Eclipse. When I try to run it on a device I get.
05-09 10:54:42.363: E/AndroidRuntime(18170): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mycompany.testAndroid/org.cocos2dx.cpp.AppActivity}: java.lang.ClassNotFoundException: Didn't find class "org.cocos2dx.cpp.AppActivity" on path: DexPathList[[zip file "/data/app/com.mycompany.testAndroid-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.mycompany.testAndroid-1, /vendor/lib, /system/lib]]
Any ideas how to fix this problem?

You application has not org.cocos2dx.cpp.AppActivity class.
Check, that required activity really exists.
For ex. if you proj.android/AndroidManifest.xml contains:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.testAndroid"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="auto">
...
<activity android:name=".AppActivity"
android:label="#string/app_name"
android:screenOrientation="landscape"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:configChanges="orientation|screenSize|smallestScreenSize»>
Then you should have proj.android/src/com/mycompany/testAndroid/AppActivity.java:
package com.mycompany.testAndroid;
import org.cocos2dx.lib.Cocos2dxActivity;
public class AppActivity extends Cocos2dxActivity {
}

Use cocos console. It is quite useful tool.
I will describe example with simple project on linux.
You should have installed ant, python, sdk, ndk, jdk, jre, cocos2dx-3
First - you should create new project. Run in terminal
cocos new TestProject -l cpp -p com.example.test
Open folder with project
cd TestProject
Run project
cocos run -p android
It will run sdk with HelloWorld example

Related

Unable to resolve service for type Microsoft.EntityFrameworkCore.Diagnostics.IDiagnosticsLogger

I am having difficulties to scaffold an existing MySQL database using EF core.
I have added the required dependencies as mentioned in the oracle doc:
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkcore.Tools" Version="6.0.0">
and then, I ran this code in the package manager console:
Scaffold-Dbcontext "server=the.server.ip.address;user=user_name;database=db_name;password=db_password;port=3306" MySql.EntityFrameworkCore -o Data -v
It shows this error:
Unable to resolve service for type
'Microsoft.EntityFrameworkCore.Diagnostics.IDiagnosticsLogger`1[Microsoft.EntityFrameworkCore.DbLoggerCategory+Scaffolding]'
while attempting to activate
'MySql.EntityFrameworkCore.Scaffolding.Internal.MySQLDatabaseModelFactory'
Here are the relevant logs in the output window:
Finding design-time services referenced by assembly 'Test2'...
Finding design-time services referenced by assembly 'Test2'...
No referenced design-time services were found.
Finding design-time services for provider 'MySql.EntityFrameworkCore'...
Using design-time services from provider 'MySql.EntityFrameworkCore'.
Finding IDesignTimeServices implementations in assembly 'Test2'...
No design-time services were found.
I don't know how shall I implement the design time classes and nor did I find any useful links in the web.
Note that I can access and run query on the database using MySQL Workbench.
I got this error not while scaffolding but when trying to create my first migration. I didn't want to downgrade to 5.0 because it would've had to be permanent since I was going to run a lot of migrations.
I fixed it by changing my provider from MySql.Data.EntityFrameworkCore to Pomelo.EntityFrameworkCore.MySql
Remove the old provider from both my API and DAL projects:
dotnet remove package MySql.EntityFrameworkCore
Add Pomelo provider
dotnet add package Pomelo.EntityFrameworkCore.MySql
Update your startup to use Pomelos configuartion:
https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#2-services-configuration
Migrations are working:
dotnet ef migrations add InitialCreate
According this description
https://bugs.mysql.com/bug.php?id=106592
you can solve this error by adding below class to your code
public class MysqlEntityFrameworkDesignTimeServices : IDesignTimeServices
{
public void ConfigureDesignTimeServices(IServiceCollection serviceCollection)
{
serviceCollection.AddEntityFrameworkMySQL();
new EntityFrameworkRelationalDesignServicesBuilder(serviceCollection)
.TryAddCoreServices();
}
}
and after define you have to add it as service in startup file
like this
services.AddSingleton<IDesignTimeServices, MysqlEntityFrameworkDesignTimeServices>();
After these steps you can migrate your code :)
I came across the same issue trying to scaffold an existing MySQL database. It looks like the latest version of MySql.EntityFrameworkCore (6.0.0-preview3.1) still uses the EFCore 5.0 libraries and has not been updated to EFCore 6.0.
It also seems Microsoft.EntityFrameworkCore.Diagnostics was last implemented in EFCore 5 and removed in 6.
When I downgraded all the packages to the 5 version level, I was able to run the scaffold command without that error.
To make Scaffold-Dbcontext work, I had to downgrade both the packages to 5.0.0 version.
MySql.EntityFrameworkCore
Microsoft.EntityFrameworkCore.Tools
After successful scaffolding, I upgraded these packages back to the their latest versions.
I could find the Core 6.0 documentation for microsoft.entityframeworkcore.diagnostics in the official website, but it was still not working when I tried the Scaffold-DbContext command. Had to downgrade all the packages to the last 5.0 version before it worked. Here are the packagerefs in my project settings
"Microsoft.EntityFrameworkCore.Design" Version="5.0.13"
"Microsoft.EntityFrameworkCore.Tools" Version="5.0.13"
"MySql.Data" Version="8.0.28"
"MySql.EntityFrameworkCore" Version="5.0.10"
#https://stackoverflow.com/users/1322226/quinestor I faced same issue and as #https://stackoverflow.com/users/9914700/james-ruth mentioned I downgraded the versions of all EFCore and EFCore Design to 5.0.8 in Visual Studio.
Did not look around for command line commands :) But we can also do it from from dotnet cli, which I guess you probably would be aware of. We can remove - dotnet remove package <PACKAGE_NAME>, and install specific version - dotnet add package <PACKAGE_NAME> --version
You do not need to perminately downgrade your EF version to scaffold, you can edit the project file to use
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.8">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="MySql.EntityFrameworkCore" Version="5.0.8" />
</ItemGroup>
Then you can run
dotnet ef dbcontext scaffold "[DSN String]" MySql.EntityFrameworkCore -o [DBName]
Then change your project file back (or revert changes) to use the latest version of EF.
Dont forget to edit the "protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)" and remove the DSN it adds to the code.
The latest version of MySql.EntityFrameworkCore still uses the EFCore 5.0 libraries and has not been updated to EFCore 6.0.
It also appears that Microsoft.EntityFrameworkCore.Diagnostics was removed in 6.
I resolve this error by adding the class below to my code:
public class MysqlEntityFrameworkDesignTimeServices : IDesignTimeServices
{
public void ConfigureDesignTimeServices(IServiceCollection serviceCollection)
{
serviceCollection.AddEntityFrameworkMySQL();
new EntityFrameworkRelationalDesignServicesBuilder(serviceCollection)
.TryAddCoreServices();
}
}
Then you must add it as a service in the initialization file
services.AddSingleton<IDesignTimeServices, MysqlEntityFrameworkDesignTimeServices>();
Hope this helps!

Unable to retrieve project metadata. Ensure it's an MSBuild-based .NET Core project

I've been researching a lot online but did not find a proper solution. I was trying to use Entity Framework Core with MySQL by using database-first scaffold method to mapping table model while always received this error when applied the command
Unable to retrieve project metadata. Ensure it's an MSBuild-based .NET Core project. If you're using custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option.
This is the command I am using to scaffold the database model:
Scaffold-DbContext "server=localhost;port=3306;user=root;password=1234;database=world" "Pomelo.EntityFrameworkCore.MySql" -OutputDir .\Models -f
And this is my .Net Core project setting:
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.1" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.0.1" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.1" />
</ItemGroup>
For EF Core 3
I think the powershell command has gone away for EF Core 3 so I'm using dotnet ef dbcontext scaffold
With this command, if you're converting a Scaffold-DbContext script the project name (parameter --project) needs to have .csproj on the end - it can't just the extensionless name.
I got this error trying to add a new migration on the command line with dotnet ef migrations add NewMigration.
The solution for me was indeed to append --msbuildprojectextentionspath obj/local.
For my case this error was solved by downloading latest dotnet-sdk-2.2.107-win-x64
for VS2017 and then dropping and updating database through cmd:
dotnet ef database drop --force --context <<dbcontext>> -s <<startup project directory>> -p <<project directory>>
dotnet ef database update --context <<dbcontext>> -s <<startup project directory>> -p <<project directory>>
Here goes the definitively solution for this problem.
I work with Rider Ide constructing a Web Api, using Net core 3 with Pomelo.MySql
I have tree layers defining my application:
Test.Domain - Class Library defining my models
Test.Infra.DataAccess - Class library defining my DbContext
Test.Service.RestApi - Net Core Api Project, where I define the AppContext in Startup file. Like This:
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContextPool<AerjDbContext>(
options => options.UseMySql(Configuration.GetConnectionString("MySqlConnectionString"),
mysqlOptions => mysqlOptions.ServerVersion(new Version(8,0,19), ServerType.MySql)
.EnableRetryOnFailure()
));
}
This is quite normal, the magic occurs here:
Initiate migrations:
dotnet ef migrations add InitialCreate --startup-project "../<Here the name of the project where startup file was configured>"
It'll create the migrations
then we have to update database with sabe command structure;
dotnet ef database update --startup-project "../<Here the name of the project where startup file was configured>"
I have tried different solutions to solve this error. Did following change in .csproj file.
Solved this issue for .Net Core by edit .csproj file and removed Import tag and then run ef command again in command line.
EF migrations with .NETCore 2.2 can be smoke-tested using migrations list:
dotnet ef migrations list --startup-project <app-startup-project-dir> --project <dal-project-dir> --context App.DAL.ApplicationDbContext
--context must point to the fully qualified name of the DbContext class that you want to manipulate.
Add this parameter to the end of your scaffold command "--msbuildprojectextensionspath".

Error when trying to Scaffold a model

I'm building a Razor Page app using ASP.NET 2017. When I run the command
dotnet aspnet-codegenerator razorpage -m Activity -dc CongContext -udl -outDir Page\Activities --referenceScriptLibraries
This error appears:
Could not load file or assembly 'Microsoft.EntityFrameworkCore,
Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
The located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040)
I stopped and restarted VS, I've also cleaned and build the solution. Attached jpg shows the code I typed and the results
This is because of different versions of packages. Check the 'Dependencies' node of your project. The Microsoft.EntityFrameworkCore and Microsoft.EntityFrameworkCore.Design must have same 2.0.3 versions.
If not, delete and re-add them from [Tools] menu > [Nuget Package Manager]. Also delete the Migrations folder and repeat instructions as listed here. For more info, you may take a look at this comment

Setup libGDX project using MOE plugin

How to setup the libGDX project using MOE plugin.
If i try to select ios-moe at the setup of libGDX project then my build fails with following error.
Generating app in
/Users/USERNAME/Desktop/PaxPlay/libGDXProjects/SampleGame Executing
'/Users/USERNAME/Desktop/PaxPlay/libGDXProjects/SampleGame/gradlew
clean --no-daemon' To honour the JVM settings for this build a new JVM
will be forked. Please consider using the daemon:
https://docs.gradle.org/2.10/userguide/gradle_daemon.html.
Configuration on demand is an incubating feature.
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring root project
'SampleGame'.
Could not resolve all dependencies for configuration ':classpath'.
Could not find com.intel.gradle:moeGradlePlugin:1.1.0.final-1.
Searched in the following locations:
file:/Users/USERNAME/.m2/repository/com/intel/gradle/moeGradlePlugin/1.1.0.final-1/moeGradlePlugin-1.1.0.final-1.pom
file:/Users/USERNAME/.m2/repository/com/intel/gradle/moeGradlePlugin/1.1.0.final-1/moeGradlePlugin-1.1.0.final-1.jar
https://repo1.maven.org/maven2/com/intel/gradle/moeGradlePlugin/1.1.0.final-1/moeGradlePlugin-1.1.0.final-1.pom
https://repo1.maven.org/maven2/com/intel/gradle/moeGradlePlugin/1.1.0.final-1/moeGradlePlugin-1.1.0.final-1.jar
https://oss.sonatype.org/content/repositories/snapshots/com/intel/gradle/moeGradlePlugin/1.1.0.final-1/moeGradlePlugin-1.1.0.final-1.pom
https://oss.sonatype.org/content/repositories/snapshots/com/intel/gradle/moeGradlePlugin/1.1.0.final-1/moeGradlePlugin-1.1.0.final-1.jar
file:/Applications/Intel/multi_os_engine/gradle/com/intel/gradle/moeGradlePlugin/1.1.0.final-1/moeGradlePlugin-1.1.0.final-1.pom
file:/Applications/Intel/multi_os_engine/gradle/com/intel/gradle/moeGradlePlugin/1.1.0.final-1/moeGradlePlugin-1.1.0.final-1.jar
Required by: :SampleGame:unspecified
Try:
Run with --stacktrace option to get the stack trace. Run with --info
or --debug option to get more log output.
BUILD FAILED
Total time: 8.492 secs Done! To import in Eclipse: File -> Import ->
Gradle -> Gradle Project To import to Intellij IDEA: File -> Open ->
build.gradle To import to NetBeans: File -> Open Project...
I had the same problem from time to time. Use the newest version of the multi os engine, which requires no local installation.
Multi-OS Engine Release 1.1.0
Samples Repository on GitHub

while using real Android device I got "Selendroid server on the device didn't came up"

I tried to automated android device Galaxy S4 (v4.2.2).
I started with the "getting started" as appear in the selendroid.io web
I used selendroid-standalone-0.10.0-with-dependencies.jar
tried to automate the app tha the web provide as training : selendroid-test-app0.10.0.ap
java jdk 1.8
ADT was installed
by typing "adb devices " - I see the android device as well
the selendroid-standalone-0.10.0-with-dependencies.jar and the app were placed in teh same folder
6.. I run the command :
java -jar selendroid-standalone-0.10.0-with-dependencies.jar -app selendroid-test-app-0.10.0.apk" -- and 4444 port was opened as needed
Now , when I tried to run the follwing code :
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import io.selendroid.SelendroidCapabilities;
import io.selendroid.SelendroidDriver;
public class login {
public static void main(String[] args) throws Exception {
SelendroidCapabilities capa = new SelendroidCapabilities("io.selendroid.testapp:0.10.0");
WebDriver driver = new SelendroidDriver(capa);
}
}
and I got the following exceptions :
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Selendroid server on the device didn't came up after 20sec:
stop the selendroid server from command prompt (press ctrl+C) and uninstall the apk in your device if the apk is already installed.
Now install the resigned apk (which is already created when you run the selendroid server previously) in your device
Now start the selendroid server from your command promt like "java -jar -aut <.apk>"
Now, run your test. It will run without any error
Even I was getting this error.
Fix :
Don't install the app under test by yourself on the device/emulator.
Let selendroid resign and install the apk by itself.