I import the Unity Audience Network SDK 5.4.1 package to unity, any version and it gives me this error:
Assets\AudienceNetwork\Editor\AudienceNetworkPostprocess.cs(25,23): error CS0234: The type or namespace name 'iOS' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)
if i remove the ios part and try to work on android only - nothing works, i try to play a reward scene and i get this error:
NullReferenceException: Object reference not set to an instance of an object
AudienceNetwork.Utility.AdUtility.IsInitialized () (at Assets/AudienceNetwork/Library/AdUtility.cs:50)
RewardedVideoAdScene.Awake () (at Assets/AudienceNetwork/Scenes/RewardedVideo/RewardedVideoAdScene.cs:21)
Is there a way to make this work? am i doing something wrong or missing something?
does the previous plugin works? any links to it?
thanks.
Without knowing what you removed the second issue is hard to tackle ...
All we can say is that it refers to the line 51
AndroidJavaObject context = currentActivity.Call<AndroidJavaObject>("getApplicationContext");
where most probably currentActivity is null if executed on a PC since the line 50 right before
AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
might not work in this case.
The first one sounds like a "bug".
You can use #if pre-processors with UNITY_IOS as a hotfix for at least making the Compiler error go away like
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
* copy, modify, and distribute this software in source code or binary form for use
* in connection with the web services and APIs provided by Facebook.
*
* As with any software that integrates with the Facebook platform, your use of
* this software is subject to the Facebook Developer Principles and Policies
* [http://developers.facebook.com/policy/]. This copyright notice shall be
* included in all copies or substantial portions of the software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace AudienceNetwork.Editor
{
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
#if UNITY_IOS
using UnityEditor.iOS.Xcode;
#endif
using UnityEngine;
public static class XCodePostProcess
{
public static string AudienceNetworkFramework = "FBAudienceNetwork.framework";
public static string AudienceNetworkAAR = "AudienceNetwork.aar";
public static string FrameworkDependenciesKey = "FrameworkDependencies";
public static string RequiredFrameworks = "AdSupport;StoreKit;WebKit";
[PostProcessBuild(100)]
public static void OnPostProcessBuild(BuildTarget target, string path)
{
#if UNITY_IOS
if (target == BuildTarget.iOS) {
string projectPath = PBXProject.GetPBXProjectPath(path);
PBXProject project = new PBXProject();
project.ReadFromString(File.ReadAllText(projectPath));
string targetName = PBXProject.GetUnityTargetName();
string targetGUID = project.TargetGuidByName(targetName);
project.AddFrameworkToProject(targetGUID, "AdSupport.framework", false);
project.AddFrameworkToProject(targetGUID, "StoreKit.framework", false);
project.AddFrameworkToProject(targetGUID, "WebKit.framework", false);
File.WriteAllText(projectPath, project.WriteToString());
}
#endif
PluginImporter[] importers = PluginImporter.GetAllImporters();
PluginImporter iOSPlugin = null;
PluginImporter androidPlugin = null;
foreach (PluginImporter importer in importers)
{
if (importer.assetPath.Contains(AudienceNetworkFramework))
{
iOSPlugin = importer;
Debug.Log("Audience Network iOS plugin found at " + importer.assetPath + ".");
}
else if (importer.assetPath.Contains(AudienceNetworkAAR))
{
androidPlugin = importer;
Debug.Log("Audience Network Android plugin found at " + importer.assetPath + ".");
}
}
if (iOSPlugin != null)
{
iOSPlugin.SetCompatibleWithAnyPlatform(false);
iOSPlugin.SetCompatibleWithEditor(false);
iOSPlugin.SetCompatibleWithPlatform(BuildTarget.iOS, true);
iOSPlugin.SetPlatformData(BuildTarget.iOS, FrameworkDependenciesKey, RequiredFrameworks);
iOSPlugin.SaveAndReimport();
}
if (androidPlugin != null)
{
androidPlugin.SetCompatibleWithAnyPlatform(false);
androidPlugin.SetCompatibleWithEditor(false);
androidPlugin.SetCompatibleWithPlatform(BuildTarget.Android, true);
androidPlugin.SaveAndReimport();
}
}
}
}
No warranty that this fixes all your issues, though.
Google Ads had a similar error and used kind of the same hotfix.
Otherwise you might want to consider installing the IOS build support which I guess would also make the error go away (but fills unnecessarily disk space of course in case you only want to build for Android)
Solution: in AdUtility.cs Add:
"#if UNITY_ANDROID && !UNITY_EDITOR"
internal static bool IsInitialized()
{
#if UNITY_ANDROID && !UNITY_EDITOR
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
Related
I want to implement a plugin architecture in Flutter Dart. The process will be as follows:
1. User downloads the app.
2. The user loads plugins from our site.
3. The apps look if the plugin implements an interface.
4. If the interface is implemented then load information and widgets from the plugin to the app.
I've implemented the same process in C# using compiled DLL loading in runtime but unable to find it for Flutter.
I've looked into some of the previous questions and resource available on the internet and the closest one I found was this, https://pub.dev/packages/plugins but the plugin is not supported in Dart 2 and deprecated
This was the code I implemented in C#.
int i = 0;
if (Directory.Exists("Plugins"))
{
dllFileNames = Directory.GetFiles("Plugins", "*.dll");
ICollection<Assembly> assemblies = new List<Assembly>(dllFileNames.Length);
foreach (string dllFile in dllFileNames)
{
AssemblyName an = AssemblyName.GetAssemblyName(dllFile);
Assembly assembly = Assembly.Load(an);
assemblies.Add(assembly);
}
Type pluginType = typeof(IPlugin);
List<Type> pluginTypes = new List<Type>();
foreach (Assembly assembly in assemblies)
{
if (assembly != null)
{
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
if (type.IsInterface || type.IsAbstract)
{
continue;
}
else if (pluginType.IsAssignableFrom(type))
{
pluginTypes.Add(type);
}
}
}
i++;
}
ICollection<IPlugin> plugins = new List<IPlugin>(pluginTypes.Count);
foreach (Type type in pluginTypes)
{
IPlugin plugin = (IPlugin)Activator.CreateInstance(type);
plugin.Initiate();
plugins.Add(plugin);
}
return plugins;
}
return null;
It's probably not possible.
Part of the AOT compilation preparing your app for upload to the stores is a tree-shaking, removing everything that isn't needed by the current build. So, anything your plugin would need to call is gone.
When I do npm run test I get back this error :
Cannot destructure property interface of 'undefined' or 'null'
I've been trying to fix this error for a cupple of days with no result. I've seen in some other posts that it's usually related with compile.js file... I think its all ok so i cannot find the issue.
I'll paste all my code (nottice I'm triyng to work with the very last version of solidity, in order to learn new functionalities... maybe there's my error...)
THANKYOU!!!
My compile.js:
const path = require('path');
const fs = require('fs');
const solc = require('solc');
const lotteryPath = path.resolve(__dirname, 'contracts', 'Lottery.sol');
const source = fs.readFileSync(lotteryPath, 'utf8');
module.exports = solc.compile(source, 1).contracts[':Lottery'];
.sol:
pragma solidity ^0.5.1;
contract Lottery {
address public manager;
address payable [] public players;
constructor() public payable {
manager = msg.sender;
}
function enter() public payable {
require(msg.value > .01 ether);
players.push(msg.sender);
}
function random() private view returns (uint){
return uint(keccak256(abi.encode(block.difficulty, now, players)));
}
function getPlayers() public view returns (address payable[] memory){
return players;
}
function pickWinner() public payable restricted{
uint index = random() % players.length;
address(players[index]).transfer(address(this).balance);
players = new address payable[](0);
}
modifier restricted(){
require(msg.sender==manager);
_;
}
}
TEST:
const assert = require ('assert');
const ganache = require ('ganache-cli');
const Web3 = require ('web3');
const provider = ganache.provider();
const web3 = new Web3(provider);
const { interface, bytecode } = require ('../compile');
let lottery;
let accounts;
beforeEach(async () => {
accounts = await web3.eth.getAccounts();
lottery = await new web3.eth.Contract(JSON.parse(interface))
.deploy({ data: bytecode })
.send({ from: accounts[0], gas: '1000000' });
});
describe('Lottery Contract', () =>{
it('deploys a contract', () =>{
assert.ok(lottery.options.address);
});
});
Heres how I fixed it:
I had the similar error when running 'npm run test'. What seemed to work for me is uninstalling your current version of solc
and running npm install --save solc#0.4.25
make the following amends in your contract and the test will run just fine.
pragma solidity ^0.4.17; //make change here
contract Lottery{
address public manager;
address[] public players;
function Lottery()public{
manager = msg.sender;
} // use this instead of using constructor
function enter() public payable{
require(msg.value>.1 ether);
players.push(msg.sender);
}
function random() private view returns(uint){
return uint(keccak256(block.difficulty, now, players));
} // make change here
function pickWinner()public{
require(msg.sender==manager);
uint index = random() % players.length;
players[index].transfer(address(this).balance);
players = new address[](0);
}
function getPlayers()public view returns(address[]){
return players;
}
}
you might have made this contract amends to make it compilable in remix but V#0.4.17 does not support this.
the same issue occur when i am trying to running a test
you can try two things:
1:try lower version of solidity. maybe V0.4.17 help you
npm uninstall solc //to uninstall existing solc version
npm i --save solc#0.4.17 //to re-install solc with lower version
2: try console.log() statement in compile.js file to check that contract is compiling or not
console.log(solc.compile(source, 1));
if the output is undefined than maybe there is some issue with your contract.
I had the exact same issue. The problem comes with the solidity compiler you are using. In my particular case I was trying 0.5.4 and for some reason I experienced the same error.
"The contract compilation is different in solc 0.5.0 and above"
one possible solution is using a lower solc version: like 0.4.25 (in my case this works fine).
The problem surges when the compilation takes place, the operation returns null, so there isn't any output and that's why you get an error telling you about the null variable.
use this in Lottery.sol :
pragma solidity >=0.4.21 <0.7.0;
contract Lottery {
address public manager;
address[] public players;
constructor() public {
manager = msg.sender;
}
function enter() public payable {
require(msg.value > 0.01 ether);
players.push(msg.sender);
}
function random() private view returns (uint) {
return uint(keccak256(abi.encodePacked(block.difficulty,now,players)));
}
function pickWinner() public restricted {
uint index = random() % players.length;
address(players[index]).transfer(address(this).balance);
players = new address[](0);
}
modifier restricted() {
require(msg.sender == manager);
_;
}
function getPlayers()public view returns(address[]){
return players;
}
}
For anyone having this issue still, make sure to console.log(solc.compile(source, 1))
Issue for me was that I named a contract something different then what I was passing as an input to .contracts[] array.
Make sure name you're passing to .contracts[] equals the name of a contract class, you can get it by consol logging the solc.compile(source, 1).
The problem is not in the js file it's in the .sol file
Make sure that you are using solidity and solc version 0.4.17
Make sure that you are not using any functions of the new solidity version in your old version like constructor
It can be a basic syntax error in your compile.js file or .sol file
Try changing the constructor function to
function Lottery() public(){ }
I want to make a short app that can post on my Facebook wall(timeline).
My app is based on webview component (QWebView) to obtain the access token for publish stream
I can take the access token but when I try to post something, on my Facebook nothing appears.
void MainWindow::on_pushButton_clicked(){
QUrl url("https://www.facebook.com/dialog/oauth");
url.addQueryItem("client_id","my_app_id");
url.addQueryItem("redirect_uri","https://www.facebook.com/connect/login_success.html");
url.addQueryItem("response_type","token");
url.addQueryItem("scope","read_stream,publish_stream");
MainWindow::browser->load(url);
MainWindow::browser->show();
}
void MainWindow::on_browser1_loadFinished(bool arg1)
{
QUrl url= browser->url();
QString strUrl = url.toString();
qDebug()<<"URL: "<<strUrl;
if( strUrl.contains(QString("access_token="), Qt::CaseSensitive)){
int sIndex = strUrl.indexOf("access_token=");
int eIndex = strUrl.indexOf("&expires_in");
QString mAccessToken= strUrl.mid(sIndex, eIndex - sIndex);
mAccessToken = mAccessToken.remove("access_token=");
qDebug()<<"TOKEN: + "<<mAccessToken;
QUrl params;
params.addQueryItem("access_token",mAccessToken);
params.addQueryItem("message","TEST !!");
params.addQueryItem("link","https://young-day-9284.herokuapp.com/");
params.addQueryItem("description","Testing");
params.addQueryItem("name","Test ");
params.addQueryItem("caption","Testing");
qDebug()<<"Mesajul trimis: "<<QString(params.encodedQuery());
QNetworkAccessManager mNetManager(this);
QNetworkRequest request(QUrl("https://graph.facebook.com/me/feed"));
//request.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
mNetManager.post(request,params.toString(QUrl::None).toAscii());
}
}
Using WebKit for this sort of program is overkill. WebKit is a full web engine and is a quite heavy component in terms of memory usage and complexity.
Try to have a look at the various OAuth implementations that exist for Qt already. For example this: https://github.com/ayoy/qoauth
QOauth even ships with some example code in the doc directory.
From Qt doc:
void QUrl::addQueryItem ( const QString & key, const QString & value ):
Note: This method does not encode spaces (ASCII 0x20) as plus (+) signs, like HTML forms do. If you need that kind of encoding, you must encode the value yourself and use QUrl::addEncodedQueryItem.
or don't use spaces.
I've just found a great sample of Facebook Connect on Blackberry by Eki Y. Baskoro,
The following is a short HOWTO on using Facebook Connect on Blackberry. I created a simple Facade encapsulating the Facebook REST API as well as added 'rough' MVC approach for screen navigation. I have tested on JDE 4.5 using 8320 simulator. This is still work in progress and all work is GPLed.
It works great for reading stuff.
NB Don't forget to get Facebook App Key and set it in TestBB class.
But now I want to post something on my wall. So I've add new method to FacebookFacade class using Stream.publish API:
/***
* Publishes message to the stream.
* #param message - message that will appear on the facebook stream
* #param targetId - The ID of the user, Page, group, or event where
* you are publishing the content.
*/
public void streamPublish(String message, String targetId)
{
Hashtable arguments = new Hashtable();
arguments.put("method", "stream.publish");
arguments.put("message", message);
arguments.put("target_id", targetId);
try {
JSONObject result = new JSONObject(
int new JSONTokener(sendRequest(arguments)));
int errorCode = result.getInt("error_code");
if (errorCode != 0) System.out.println("Error Code: "+errorCode);
} catch (Exception e) {
System.out.println(e);
}
}
/***
* Publishes message on current user wall.
* #param message - message that will appear on the facebook stream
*/
public void postOnTheWall(String message)
{
String targetId = String.valueOf(getLoggedInUserId());
streamPublish(message, targetId);
}
This will return Error code 200, "The user hasn't authorized the application to perform this action"
First I thought it's related with Facebook -> Application Settings -> Additional Permissions -> Publish recent activity (one line stories) to my wall but even checked, no difference...
Then I've found this post explains that issue related with extended permissions.
This in turn should be fixed by modifying url a little in LoginScreen class :
public LoginScreen(FacebookFacade facebookFacade) {
this.facebookFacade = facebookFacade;
StringBuffer data = new StringBuffer();
data.append("api_key=" + facebookFacade.getApplicationKey());
data.append("&connect_display=popup");
data.append("&v=1.0");
//revomed
//data.append("&next=http://www.facebook.com/connect/login_success.html");
//added
data.append("&next=http://www.facebook.com/connect/prompt_permissions.php?" +
"api_key="+facebookFacade.getApplicationKey()+"&display=popup&v=1.0"+
"&next=http://www.facebook.com/connect/login_success.html?"+
"xxRESULTTOKENxx&fbconnect=true" +
"&ext_perm=read_stream,publish_stream,offline_access");
data.append("&cancel_url=http://www.facebook.com/connect/login_failure.html");
data.append("&fbconnect=true");
data.append("&return_session=true");
(new FetchThread("http://m.facebook.com/login.php?"
+ data.toString())).start();
}
Unfortunately it's not working. Still Error Code 200 in return to stream.publish request...
Do you have any suggestions how to resolve this?
Thank you!
I have posted the updated API on my website (http://www.baskoro.web.id/facebook-connect-blackberry-HOWTO.html) and this should solve this issue. Please let me know otherwise.
Salam. Cheers!
Eki
We are upgrading some of our systems including a move up to jUDDI V3 from V2. In the past we used uddi4j in our java code to access the UDDI server, but uddi4j doesn't seem to have continued to V3. Extensive Google time leaves me thinking there is no substitute. Is this the case? If there are alternatives can you recommend one?
as far as I know jUDDIv3 brings its own UDDI client.
see: http://www.redhat.com/docs/en-US/JBoss_SOA_Platform/5.0.0-Beta1/html/jUDDI_User_Guide/chap-Using_jUDDI-Client.html
I didn't find the lib as a separate download but it is included in the juddi-portal-bundle.
Yes, jUDDI has its own UDDIv3 client.
Here's the maven details
<dependency>
<groupId>org.apache.juddi</groupId>
<artifactId>juddi-client</artifactId>
<version>3.1.5</version>
</dependency>
There's tons of examples in the current source trunk, all of which will be bundled with future versions. The examples can be found here:
http://svn.apache.org/repos/asf/juddi/trunk/juddi-examples/
The jUDDI user guide is also a great reference too.
i try the following code in 3.0.4 juddi portal bundle
/*
* Copyright 2001-2010 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import org.apache.juddi.api_v3.Publisher;
import org.apache.juddi.api_v3.SavePublisher;
import org.apache.juddi.v3.client.ClassUtil;
import org.apache.juddi.v3.client.config.UDDIClientContainer;
import org.apache.juddi.v3.client.transport.Transport;
import org.apache.juddi.v3_service.JUDDIApiPortType;
import org.uddi.api_v3.AuthToken;
import org.uddi.api_v3.BusinessDetail;
import org.uddi.api_v3.BusinessEntity;
import org.uddi.api_v3.BusinessService;
import org.uddi.api_v3.GetAuthToken;
import org.uddi.api_v3.Name;
import org.uddi.api_v3.SaveBusiness;
import org.uddi.api_v3.SaveService;
import org.uddi.api_v3.ServiceDetail;
import org.uddi.v3_service.UDDIPublicationPortType;
import org.uddi.v3_service.UDDISecurityPortType;
public class SimplePublish {
private static UDDISecurityPortType security = null;
private static JUDDIApiPortType juddiApi = null;
private static UDDIPublicationPortType publish = null;
public SimplePublish() {
try {
String clazz = UDDIClientContainer.getUDDIClerkManager(null).
getClientConfig().getUDDINode("default").getProxyTransport();
Class<?> transportClass = ClassUtil.forName(clazz, Transport.class);
if (transportClass!=null) {
Transport transport = (Transport) transportClass.
getConstructor(String.class).newInstance("default");
security = transport.getUDDISecurityService();
juddiApi = transport.getJUDDIApiService();
publish = transport.getUDDIPublishService();
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void publish() {
try {
// Setting up the values to get an authentication token for the 'root' user ('root' user has admin privileges
// and can save other publishers).
GetAuthToken getAuthTokenRoot = new GetAuthToken();
getAuthTokenRoot.setUserID("root");
getAuthTokenRoot.setCred("");
// Making API call that retrieves the authentication token for the 'root' user.
AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot);
System.out.println ("root AUTHTOKEN = " + rootAuthToken.getAuthInfo());
// Creating a new publisher that we will use to publish our entities to.
Publisher p = new Publisher();
p.setAuthorizedName("my-publisher");
p.setPublisherName("My Publisher");
// Adding the publisher to the "save" structure, using the 'root' user authentication info and saving away.
SavePublisher sp = new SavePublisher();
sp.getPublisher().add(p);
sp.setAuthInfo(rootAuthToken.getAuthInfo());
juddiApi.savePublisher(sp);
// Our publisher is now saved, so now we want to retrieve its authentication token
GetAuthToken getAuthTokenMyPub = new GetAuthToken();
getAuthTokenMyPub.setUserID("my-publisher");
getAuthTokenMyPub.setCred("");
AuthToken myPubAuthToken = security.getAuthToken(getAuthTokenMyPub);
System.out.println ("myPub AUTHTOKEN = " + myPubAuthToken.getAuthInfo());
// Creating the parent business entity that will contain our service.
BusinessEntity myBusEntity = new BusinessEntity();
Name myBusName = new Name();
myBusName.setValue("My Business");
myBusEntity.getName().add(myBusName);
// Adding the business entity to the "save" structure, using our publisher's authentication info and saving away.
SaveBusiness sb = new SaveBusiness();
sb.getBusinessEntity().add(myBusEntity);
sb.setAuthInfo(myPubAuthToken.getAuthInfo());
BusinessDetail bd = publish.saveBusiness(sb);
String myBusKey = bd.getBusinessEntity().get(0).getBusinessKey();
System.out.println("myBusiness key: " + myBusKey);
// Creating a service to save. Only adding the minimum data: the parent business key retrieved from saving the business
// above and a single name.
BusinessService myService = new BusinessService();
myService.setBusinessKey(myBusKey);
Name myServName = new Name();
myServName.setValue("My Service");
myService.getName().add(myServName);
// Add binding templates, etc...
// Adding the service to the "save" structure, using our publisher's authentication info and saving away.
SaveService ss = new SaveService();
ss.getBusinessService().add(myService);
ss.setAuthInfo(myPubAuthToken.getAuthInfo());
ServiceDetail sd = publish.saveService(ss);
String myServKey = sd.getBusinessService().get(0).getServiceKey();
System.out.println("myService key: " + myServKey);
// Now you have a publisher saved who in turn published a business and service via the jUDDI API!
}
catch (Exception e) {
e.printStackTrace();
}
}
public static void main (String args[]) {
SimplePublish sp = new SimplePublish();
sp.publish();
}
}
and use the following library
maven depandency
<dependency>
<groupId>org.apache.juddi</groupId>
<artifactId>juddi-client</artifactId>
<version>3.0.2</version>
</dependency>
and this jar file
axis2-adb-1.5.4.jar
thats it and my code is working fine